4
votes

How to set Textfield's maximum width?
I need auto-width until it gets to maximum width, so long text will break into lines.

1

1 Answers

5
votes
var maxWidth:Number = 200;

textField.multiline = false;
textField.wordWrap = false;
textField.autoSize = TextFieldAutoSize.LEFT;

textField.text = "Lorem ipsum";

if (textField.width > maxWidth)
{
    textField.multiline = true;
    textField.wordWrap = true;
    textField.width = maxWidth;
}