ice987
April 18, 2006, 8:22pm
1
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;
ice987
April 18, 2006, 8:24pm
2
Ignore the spaces in my code. These were added when I uploaded the page
thumbTitle_txt.autosize="center";
:-/
isnt it
thumbTitle_txt.autosize=true;
nathan99:
ActionScript Code:
[FONT=Courier New][LEFT]thumbTitle_txt.[COLOR=#0000ff]autosize[/COLOR]=[COLOR=#ff0000]“center”[/COLOR];
[/LEFT]
[/FONT]
:-/
isnt it
ActionScript Code:
[FONT=Courier New][LEFT]thumbTitle_txt.[COLOR=#0000ff]autosize[/COLOR]=[COLOR=#000000]true [/COLOR];
[/LEFT]
[/FONT]
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: