I’m trying to stack (from top down) a bunch of text fields in a loop. The height of the text fields is variable because some of the text breaks into 2 or more lines. My idea is to look at the height of the parent movieclip and use that to set the y cood of each new text field. Problem is that it doesn’t seem to see when lines break and the text fields that come after textfields with 2 or more lines end up overlapping the prev text field.
Now, the really goofy thing is, when I added a trace after the creating of each new text field, to see what was going on, the code works as expected…!
Here’s the code:
for (var i:Number = 0; i<attractions.length; i++) {
var txt:TextField = listHolder.createTextField("listItem_txt"+i, i, 0, 0, 200, 0);
// this makes it work! Remove the trace, and text fields overlap??
trace(listHolder._height);
txt._y = listHolder._height;
txt.multiline = true;
txt.wordWrap = true;
txt.selectable = false;
txt.autoSize = true;
txt.embedFonts = true;
var myFilters:Array = txt.filters;
myFilters.push(myDropFilter);
txt.filters = myFilters;
txt.text = attractions*.title;
txt.setTextFormat(txtFormat);
}
What is this madness?
EDIT: I tried using textHeight but got the same results. I read in another post that flash can’t update either height property fast enough. You need to use a work around such as adding a couple of lines of frivolous code after the textfield gets populated. Really??? Is there not another way? Did this get fixed in AS3/FP9?