Text Alignment not working, did I do something wrong?
Here's the deal, I have a TextField that I want to align centered. it is a dynamic TextField, so I want to use AutoSize.
The problem is, I've tried TextFieldAutoSize and TextFormatAlign. Nothing works. The text is still aligned at left (the size expands to the right)
The whole code:
var usernameStringFormat:TextFormat = new TextFormat();
usernameStringFormat.align = TextFormatAlign.CENTER;
usernameStringFormat.font = "Space Age";
usernameStringFormat.size = 28;
usernameStringFormat.color = 0xff6000;
var username:TextField = new TextField();
username.defaultTextFormat = usernameStringFormat;
//username.autoSize = TextFieldAutoSize.CENTER;
username.text = "LOREM IPSUM";
//username.setTextFormat(usernameStringFormat);
I've tried these combos:
Only TextFormatAlign
Only TextField AutoSize
Both Align and AutoSize
all three of them implemented with these combos:
Only defaultTextFormat
Only setTextFormat
Both defaultTextFormat and setTextFormat
Nothing works. I'm going nuts here.
EDIT:
Okay, I got past this nutcase. I simply used username.x - = username.width/2; subsequent additions to the text property causes the textfield to expand properly to the left and right. Is this the way it is intended?