Find a text field name using a variable
Hello, I know this may be very basic, so I apologize in advance for that, but I just can´t figure it out after a couple of hours of Google it, so if anyone can help me, that would be great! Thanks in advance!
I have three dynamic text fields in my stage, called txt1, txt2 and txt3.
I want to put some data in them, but I want to find them using a variable:
var i: int = 1;
while (i < 4)) {
var textTemp : String = i.toString();
textTemp = "txt" + textTemp;
trace(textTemp); // So far, so good: in the Console, I get txt1, txt2 and txt3
i++;
// Now, lets say I want to set each text field to any text, it doesn´t really matter. So I try this:
textTemp.text = "This is a test"; // This didn´t work
TextField[textTemp].text1 = "This is a test"; // Neither this
}
Thanks again, I´m really lost here!
