ActionScript 2, list of nested movieclips

13,518

Solution 1

Are you just trying to trace? If so there's a nice little undocumented utility called ObjectDumper that can do this.

This is probably the best explanation of it out there

So what you can do is this:

import mx.data.binding.ObjectDumper;

trace(ObjectDumper.toString(_root));

There may be a lot of extras (functions, variables, etc) in there, so there are additional parameters you can use:

ObjectDumper.toString(obj, showFunctions, showUndefined, showXMLstructures, maxLineLength, indent)

Solution 2

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...

Solution 3

You can do something like that by adding a function to the MovieClip class:

MovieClip.prototype.StopEverything = function()
{
    stop();
    for (var i in this) {
        if (typeof(this[i]) == "movieclip") {
            this[i].StopEverything();
        }
    }
}
ASSetPropFlags(MovieClip.prototype, ["StopEverything"], 1);

That last bit ASSetPropFlags is something I found that allows StopEverything to iterate over built-in classes like MovieClip using for..in for every field, even hidden properties and items. Without ASSetPropFlags, StopEverything() might not hit every contained movie clip.

Share:
13,518
Admin
Author by

Admin

Updated on June 04, 2022

Comments

  • Admin
    Admin almost 2 years

    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!

  • Admin
    Admin about 15 years
    The fact is that a specific level can "host" dozens of movieclips: you can have one, as you can have 100. So a recursive function (that for sure IS the way) could easily become a very "consuming" task.
  • Admin
    Admin about 15 years
    Hi, very valuable suggestion: I totally ignored the existence of ObjectDumper. I can't try at the moment: my goal is not exactly the trace but to stop all the movieclips, even the nested ones, found in stage at the current frame.
  • Admin
    Admin about 15 years
    If the ObjectDumper.as code is this elegancia2.com/TestSite/mx/data/binding/ObjectDumper.as I'm not sure it works with movieclips.
  • Admin
    Admin about 15 years
    I've no real control: they provide me with compiled swf made by third party content developers and I should control all the timelines of all the movieclips at the currentframe using the main videorecorder commands.
  • Admin
    Admin about 15 years
    Btw, here is our function: function stopMCs(mc:MovieClip):Void { mc.stop(); for (i in mc) { if (mc[i] instanceof MovieClip) { mc[i].stop(); stopMCs(mc[i]); } } }
  • Admin
    Admin almost 15 years
    I posted a similar solution in a comment (Feb 2 at 20:01).