Text creation

hi there,

I’ve posted questions like this one before, but never really got any good awnsers or hints. Or at least nothing that was clear to me.

I need to dynamically create an empty textfield with the variable “content”

Then I need to resize the component to the amount of text thats in it. ( I use the variable “content” for the contents of the new textfield) So the bigger the information stored in “content” The bigger my textfield.

Then I need the textfield to align to the center of the stage. both horizontally as vertically.

This is all supposed to be done using actionscript. I need the actionscript code. I’ve used the Flash actionscript dictonairy for more information but didn’t really understand it.

thanks in advance.


ps this is something ive tried…

text.createTextField(text, 1, 20, 20, 200,200);
text.setNewTextFormat(variable = “_root.content”, align= “center”, font = “Verdana”, size = “16”);

HELP ME :slight_smile:

content = "hello there";

format = new TextFormat("Verdana",16);
format.align = "center";

text.autoSize = "center";
text.variable = "content";

text._x = Stage.width/2 - text._width/2;
text._y = Stage.height/2 - text._height/2;

hi there,

thanks very much for this little bit of code. really useful.

didn’t understand the align part at the end at first but figured it out.

thank you very much.