I want to populate the stage with a list of dynamic text fields with individual names, something like pg4_txt1, pg4_txt2, pg4_txt3. I'm a novice at flash, I tried creating variables with a while loop, but I just haven't got the grasp of it.
Here's some kind of weird pseudo code to explain what I want to do:
var leading:Number = 15;
var i:Number = 0;
while (i<14) {
leading+leading; //using this to set the y position
createTextField("dynamic_txt+[i]", 1, 10, 10+leading, 150, 30); //Create 15 text fields vertically spaced
}
Update - Trying this code (from PatrickS) just creates on varialble -dynamic_txt14
var leading:Number = 0;
for( var i:Number = 0; i < 15 ; ++i )
{
var tfName:String = "dynamic_txt" + i.toString();
//Create 15 text fields vertically spaced
createTextField(tfName , 1, 10, 10, leading, 50, 30);
trace(tfName);
// a slight improvement to the leading incrementation :)
leading += 10; //using this to set the y position
}
dynamic_txt14.text = "hello!";
EDIT - Solution
var leading:Number = 11;
var myTxtField:TextField;
for (i=0; i<15; i++) {
textBoxes = "dynamic_txt"+i;
this.createTextField(textBoxes, this.getNextHighestDepth(), 250, leading, 100, 300, 100);
myTxtField = this[textBoxes]
myTxtField.text = "hello";
trace(myTxtField.text);
leading += 20;
}