loop counter to variable name


i have 4 sprites named sprite1, sprite2, sprite3, , sprite4. each of them contains textfield called mytextfield. trying make loop following, syntax must wrong:

 

for (var i:uint=1; i<=4; i++) {

     this["sprite"+i].mytextfield.text = i;

}

 

when run debugger "error #1010: term undefined , has no properties." can figure i'm doing wrong?

try using instead:

 

for (var i:uint=1; i<=4; i++) {

     this.getchildbyname("sprite"+i).mytextfield.text = i;

}

 

and make sure sprites sit on level call from



More discussions in ActionScript 3


adobe

Comments

Popular posts from this blog

Upgrade 3.4.8 to 3.5.1 failed "download package failed" - Joomla! Forum - community, help and support

Joomal 3.6.3 update error - PHP temporary folder is not set - Joomla! Forum - community, help and support

Fatal error during instalation - Joomla! Forum - community, help and support