views:

32

answers:

1

Lest just say i have a movieClip A which contains movieClips B1,B2,B3,B4,B5

I write code in A to receive all movieclips that a contains and like print there name.

i tried this with no succes:

for each (a:MovieClip in this)
    trace(a.name);

does anyone know how to get this working.

** note the trace name is actually an example i want to do very different things with the objects itself like changing there visibility and such **

thanks, Matthy

+1  A: 

I'm not sure if I completely understand what you're trying to do, but you could do something like this to pull their instance names from a parent movielcip:

for(var i:int = 0; i < target_mc.numChildren; i++) {
trace (target_mc.getChildAt(i).name);
}

You can also pull out more information such as the type of object with something a little more verbose:

for(var i:int = 0; i < target_mc.numChildren; i++) {
trace ('\t|\t ' +i+'.\t name:' + target_mc.getChildAt(i).name + '\t type:' + typeof 
(target_mc.getChildAt(i))+ '\t' + target_mc.getChildAt(i));
}
Ian
thanks it works! never knuw the "numchildren property"
matthy