I’m trying to set the width of a Textfield() object based on it’s string content that I have set-
Is there a way to dynamically set this once the string has been sent to the object?
I have:
var t1:TextField = new TextField()
t1.x = stage.stageWidth / 2;
t1.y = stage.stageHeight / 2;
t1.text = "some string that i would want to render";
t1.textColor = 0x000000;
t1.cacheAsBitmap = true;
addChild(t1);
Thanks for any suggestions…
jml
TextField.autoSize?
edit:
You should read the documentation correctly, it’s a member variable that actually needs to be set. I’ll give you a quick example on how this works:
Alternatively you can also align the text field first and use
TextFieldAutoSize.CENTERto keep it aligned in the center.