hi. i have 3 dinamic text (h1,h2,h3) but i can´ t do this
var n:Array=["n1","n2","n3"];
for(var i = 0;i < 3; i++){
n[i].text="hello";
}
say this error Cannot create property text on String. help me sorry for my ingles
hi. i have 3 dinamic text (h1,h2,h3) but i can´ t do this
var n:Array=["n1","n2","n3"];
for(var i = 0;i < 3; i++){
n[i].text="hello";
}
say this error Cannot create property text on String. help me sorry for my ingles
The reason you're getting this error is because the array n contains 3 strings (n1, n2 and n3). So when you say: n[i].text, you are trying to set a non-existent property on a string.
If h1, h2 and h3 are the instance names of your text boxes, in your loop use this instead:
this["h"+i+1].text = "hello";
This code will reference the h1, h2 and h3 text boxes now. The reason there is a +1 added to i is because you are starting at 0, yet your first text box has a 1.