Using inputFields to change movieClip propeties

Hi,

This is my first time working with inputFields in Actionscript 3.0 and I’m lost.

What I want to do is create two input fields and one button, one inputField to control the width of a rectangular movieClip and the other inputField to control the height of the same movieClip and be able to use the button to change the size of the movieClip with a CLICK event.

Can some be so kind and show me how to do something like this?

Thanks


mybtn.addEventListener(MouseEvent.CLICK, clickHandler);

private function clickHandler(evt:MouseEvent):void{
mymc.width=Number(input1_txt.text);
mymc.height=Number(input2_txt.text);
}

Obviously you can go and append the code to make sure the value entered in the textboxes are only numbers and that the textboxes are not blank.

First of all thank you very much!

Obviously you can go and append the code to make sure the value entered in the textboxes are only numbers and that the textboxes are not blank

How is this done?

Thanks

Check up the properties of input textbox, there must be a property called restrict where you can just specify a range like 0-9, you can always do check that the textboxes are not blank by using an if condition which would fire up an Alert or something if textbox.text==“”, whenever mybtn is clicked.

Thanks a lot for your reply!

Totally out of the blue, I haven’t used more than adding a url to a button like 2 years ago…
but can one use regexes in Actionscript 3 to do the above (limit user input)?

Actionscript 3 has an in built regex class so yes, though you’d be processing the input after it was typed and then resetting the input field instantaneously rather than directly disallowing input.