actionscript 3 - referring to textfields in for loop -


i've looked how can , nothing seems work. trying use in loop refer textfields , set them. suppose textfields named textfield0, textfield1, textfield2, etc. like:

for(var i:int = 0; < numberoffields; i++) {   parent.child.getchildbyname("textfield" + i).text = stringarray[i]; } 

any appreciated thanks

let's assume hierarchy looks this

0: root:maintimeline ¬     0: background:shape     1: textfield1:textfield     2: textfield2:textfield     3: myclip:movieclip     4: textfield3:textfield 

we've got "noise" in list, straight-up iteration on might not best way. could, , place if statement tests name of object, or object type, or create manual list of pointers each of these textfields. in scenario, each textfield hypothetically exist in nested container. depends on have set up.

in example gave above, you're referencing object literally called "child", mean hierarchy might this...

0: root:maintimeline ¬     0: child:movieclip ¬         0: textfield1:textfield         1: textfield2:textfield         2: textfield3:textfield     1: myclip:movieclip // <- assuming class code coming 

so, logic have go level implicit this reference (this.parent == parent), , down our container named child, , iterate on children (note: suspect not case, , part of reason failing).

assuming same hierarchy, might rewrite way:

for (var i:int = 0; < parent.child.numchildren; i++) {     var txt:textfield = parent.child.getchildat(i);     txt.text = stringarray[i]; } 

Comments

Popular posts from this blog

php - get table cell data from and place a copy in another table -

javascript - Mootools wait with Fx.Morph start -

php - Navigate throught databse rows -