ActionScript 2, list of nested movieclips

vyger picture vyger · Jan 30, 2009 · Viewed 13.5k times · Source

has anyone ever tried to get the list of all the movieclips (even the nested ones) that are on Stage at a specified stopped (and current) frame in Flash 8, AS 2?

I did the following:

for(i in _root){
if(typeof(_root[i])=="movieclip"){
trace(_root[i]);}
}

But this is good for a first level search: that is, if inside the movieclips you have other movieclips, you can't reach them. Furthermore, inside a movieclip there can be more then one movieclip.

Has anyone ever tried to do what I'm trying to do?

Bye!

Answer

Steffen picture Steffen · May 31, 2010

exactly as suggested by inkedmn

printStuff first checks to see if the value it finds is a mc then if it is, traces and then checks inside it for more mcs.

printStuff = function(object){
    for(var x in object){
        if(typeof(object[x])=="movieclip"){
            trace(object[x]);
            printStuff(object[x]);
        }
    }
}
printStuff(_root);

oh....and sorry for being a year and some change late...