Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Text box problem

New Here ,
Jan 28, 2013 Jan 28, 2013

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!

TOPICS
ActionScript
660
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 28, 2013 Jan 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 28, 2013 Jan 28, 2013

Thanks!

Thats one down, one to go

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 28, 2013 Jan 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;
     }

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 28, 2013 Jan 28, 2013

Hi Ned, thank you for answering!

I have a question regarding the first method-if I already created a text box on the stage, can I apply it for that text box?

Cause' right now I'm getting for that line:

1120: Access of undefined property TextFieldAutoSize.

Or I must define the that box by code?

Thank you!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 31, 2013 Jan 31, 2013
LATEST

Yes, you can apply it to a textfield that you place on the stage.  How did you write the code?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines