Creating unique textFields in a For loop.
I have a for loop that runs depending on the length of an XML file. What I want to do is create a unique text field for each run through of the loop, and give it it's own position on the stage, and finally assign it the text from an external text file that is specified in the XML file. Everything I know how to do except creating the textfields.
Quote:
for(var i:int = 0; i < blogXMLList.length(); i++)
{
var txtHolder:TextField = new TextField();
txtHolder.x = textX;
txtHolder.y = textY;
txtHolder.width = textX;
txtHolder.height = textY;
txtHolder.multiline = true;
txtHolder.wordWrap = true;
textX += 50;
textY += 50;
addChild(txtHolder);
blogPostRequest = new URLRequest(blogXMLList[i].attribute("file"));
blogPostLoader.load(blogPostRequest);
blogPostLoader.addEventListener(Event.COMPLETE, loadTXT);
function loadTXT(event:Event):void
{
txtHolder.text = event.target.data;
}
}
This code creates only one Text Field, but then replaces it's text with new text with each run through. Please help, this has been annoying me for quite a while.