Skip to main content
Known Participant
January 28, 2013
Question

Text box problem

  • January 28, 2013
  • 1 reply
  • 697 views

Hi everyone!

I have a problem regarding text boxs.

Lets say I created a text box, and I want to limit the number of input  characters\numbers to 3, how can I do that?

Alternatively, can I make that size of the text box change (expand) during input so the text doesnt "disappear" while exiting the borders of the text box? (Assuming that even possible)...

If anyone can write the code, or refer me to the relevant part in the manual (I didn't fint it) I'll be greatful.

Thank you!

This topic has been closed for replies.

1 reply

January 28, 2013

Hi,

I do not have idea about dynamically change the width of text box but for limit the number of characters you can use this :

public var txtName:TextField;

 

  public function test():void

  {

          txtName = new TextField();

           txtName.maxChars = 3;

  }

Vipul

Sason922Author
Known Participant
January 28, 2013

Thanks!

Thats one down, one to go

Ned Murphy
Legend
January 28, 2013

There are a couple of ways I can think of to approach changing the width of the input textfield ("it" below). 

One is to just use the autoSize property...

     it.autoSize = TextFieldAutoSize.LEFT;

and the other is to adjust the width based on the width of the text inside the textfield....

     it.addEventListener(Event.CHANGE, resizeIT);

     function resizeIT(evt:Event){
         it.width = it.textWidth;
     }