How to access instances/ duplicated movie clip?


hi, i'm new , still confuse how duplicate movieclip in as3 access instances. try write code:

 

for (var i=1; i<5; i++)

{

var mc:mc = new mc();

mc.name = string ("mc_"+i);

addchild(mc);

mc.x = 20 * ;

mc.y = 0;

trace (mc.name);

}

 

when run code, see that  have mc_1, mc_2, mc_3, , mc_4 , can see them in stage.

but why can't manualy access them calling name , put action in it? example this:

 

for (var i=1; i<5; i++)

{

var mc:mc = new mc();

mc.name = string ("mc_"+i);

addchild(mc);

mc.x = 20 * ;

mc.y = 0;

trace (mc.name);

}

 

mc_1.x-=3;

removechild(mc_2);

mc_3.y+=3;

mc_4.x+=2;

 

if run got "1120: access of undefined property mc_1,2,3,4" error message.

i want call/access each instance individually outside loop/for code. possible?

anyone can help, please?

a reference , name not same (unless create object in ide).

 

use getchildbyname() reference objects same reference (mc) , different names:

 

this.getchildbyname("mc_2").x -= 3;

//etc



More discussions in ActionScript 3


adobe

Comments

Popular posts from this blog

Some mp4 files not displaying correctly (CS6)

Thread: Samba is not authenticating with LDAP