Hi all,
I have text that loads into a dynamic text field that is on the stage. The movie clip(“tile” in code below) in which the dynamic text field resides is placed on the stage via loop function.
I can load the text from the xml file just fine.
However, since each text field in loop autosizes, which is what I want, (in height only-width is fixed), I want the next text in the loop to load in a Y position based on the previous text box height including a “cushion” of my choosing.
I’m very close, but can’t seem to get the math right that is needed for the tiles Y position…I’m thinking this should be simple
Here it is:
var xmlLoader:URLLoader = new URLLoader();
xmlLoader.load(new URLRequest("faq.xml"));
xmlLoader.addEventListener(Event.COMPLETE, onXMLLoad, false, 0, true);
//on news.xml load
function onXMLLoad(event:Event):void {
var newsXML:XML = new XML(event.target.data);
newsXML.ignoreWhitespace = true;
for (var i:int = 0; i<newsXML.item.length(); i++) {
var tile:Tile = new Tile();
tile.headerTxt.htmlText = newsXML.item*.name.text();
//get content from <txt> tags. Then add data from <linkurl> and <linkname>
tile.infoTxt.htmlText = newsXML.item*.txt.text()+" <font color='#FFFFFF'> <a href='"+newsXML.item*.linkurl.text()+"'>"+newsXML.item*.linkname.text()+"</a></font>";
tile.infoTxt.multiline = true;
tile.infoTxt.autoSize = TextFieldAutoSize.LEFT;
tile.infoTxt.width = 610;
//**HERE IS MY ISSUE:***
tile.y = tile.height*30*i; // = spacing between the tiles
trace ("tile " + i + " y position: " + tile.y);
trace("tile " + i + " height property = " + tile.height);
trace("");
scrlContainer.addChild(tile);
}
}