R – flash – AS3 parallel of evel in AS2

actionscript-3flash

the idea is to access MC's on the stage with sequantial instance names,
for example: mc1, mc2, mc3 …

now, in as2 i would do: this["mc" + i]
(where "i" represents a number between 1-3)

how would i do such thing in as3?

thanks in advance

Best Answer

If mc1,mc2,mc3 are located on the top level of your fla, and there are no other clips bellow them ( e.g. mc1 has has depth(index) 1, mc2 has index 2, etc. ) you could get the clips using getChildAt();

for(var i:int = 1 ; i < 3 ; i++){
var clip:MovieClip = MovieClip(getChildAt(i));
}

if you're not sure about depth management, just name your clips ( if they're on stage, give them instance names, if they're created at runtime, use the name property (mc1.name = 'mc1'))

and use getChildByName() to get them

for(var i:int = 1 ; i < 3 ; i++){
var clip:MovieClip = MovieClip(getChildByName('mc'+i));
trace(' got clip named: ' + clip.name);
}

I'm sure there a lot of resouces if you just google as2 as3 migration

Related Topic