I've been looking around all day and havent had any luck finding a solution for this.
What im looking to do is dynamically create TextFields based on my array.length. So if I have 3 strings in my array then 3 TextFields with the array text needs to be created.
I've managed to actually create TextFields based on the array.length - however afterwards I dont know how to reference them individually, to lets say re-position x, y for array[1]. I've tried saving the Textfields in another array by .push method, but can't seem to reference them correctly.
Any suggestions?
//Create textfields based on data in Array - in this case 3 textfields
var textArray:Array = new Array('First TextField','TextField Two','Anything, really');
//Array to .push "save" created textfields
var referenceArray:Array = new Array();
// Creating font instance
var garageInstance:Font = new garage();
var myFormat:TextFormat = new TextFormat();
//Embedding font
myFormat.font = garageInstance.fontName;
myFormat.color = 0xFFFFFF;
myFormat.size = 46;
myFormat.align = TextFormatAlign.CENTER;
for (var i:int; i < textArray.length; i++)
{
//Creating the textfield object and naming it "myTextField2"
var myTextField2:TextField = new TextField();
myTextField2.defaultTextFormat = myFormat;
myTextField2.width = 930;
myTextField2.embedFonts = true;
myTextField2.multiline = true;
myTextField2.wordWrap = true;
myTextField2.selectable = false;
myTextField2.htmlText = textArray[i];
myTextField2.autoSize = TextFieldAutoSize.CENTER;
//Here we add the new textfield instance to the stage with addchild()
addChild(myTextField2);
//Saving textfield into array
referenceArray.push(myTextField2);
}