Textfields

I am tring to create textfields on the fly that wrap the text they contain. I am using the following code but it is not working well. The text within the textfield is low and some of it is cut off.(Easy to see if I put a border around the textfield.) What’s my bext solution to create a textfield which perfectly fits the text it contains.

var caption=“someText”;

thumbTitleTextFormat=new TextFormat();
thumbTitleTextFormat.font=“exportedArialFont”;
thumbTitleTextFormat.align=“center”;
thumbTitleTextFormat.size=20;
thumbTitleTextFormat.color=0xFFFFFF;

createTextField(“thumbTitle_txt”,13,0,0,0,0);
thumbTitle_txt.setNewTextFormat(thumbTitleTextFormat);
thumbTitle_txt.autosize=“center”;
thumbTitle_txt.embedFonts=true;

thumbTitle_txt._width=thumbTitleTextFormat.getTextExtent(caption).width;
thumbTitle_txt._height=thumbTitleTextFormat.getTextExtent(caption).height;
thumbTitle_txt.text=caption;

Ignore the spaces in my code. These were added when I uploaded the page

thumbTitle_txt.autosize="center";

:-/

isnt it

thumbTitle_txt.autosize=true;

It depends on what side of the text field you want to remain static. But the “s” in autoSize should be capitalized:

var caption = "someText";
thumbTitleTextFormat = new TextFormat();
thumbTitleTextFormat.font = "exportedArialFont";
thumbTitleTextFormat.align = "center";
thumbTitleTextFormat.size = 20;
thumbTitleTextFormat.color = 0xFF0000;
createTextField("thumbTitle_txt", 13, 0, 0, 0, 0);
thumbTitle_txt.setNewTextFormat(thumbTitleTextFormat);
thumbTitle_txt.autoSize = "center";
thumbTitle_txt.embedFonts = true;
thumbTitle_txt._width = thumbTitleTextFormat.getTextExtent(caption).width;
thumbTitle_txt._height = thumbTitleTextFormat.getTextExtent(caption).height;
thumbTitle_txt.text = caption;

:cons: