user2003548
user2003548

Reputation: 4545

how to manipulate movieclip with nested movieclip inside?

i want to fasten the movie clip playing speed twice time, here's the code

mc.addEventListener(Event.ENTER_FRAME,function(e:Event):void{
    mc.nextFrame();
});

this works if the movie clip only had one level.but with a nested movieclip, it can't help. when call mc.stop(); the nested movie clip won't stop.i dispatch various event,like enter frame,EXIT FRAME,RENDER to their parent hope make them move to the next frame,but nested movie clip just won't move.

thought there's one way left to get all movieclip object under that movieclip to make them move,but that's not a good choice, since i cant predict what code inside there.

Upvotes: 0

Views: 388

Answers (1)

Marty
Marty

Reputation: 39466

You could use a function like this:

function callOnChildren(container:DisplayObjectContainer, method:String, args:Array = null):void
{
    for(var i:int = 0; i < container.numChildren; i++)
    {
        var child:DisplayObject = container.getChildAt(i);
        child[method].apply(child, args);
    }
}

And then call nextFrame() on all children like so:

callOnChildren(mc, "nextFrame");

Other methods work too:

callOnChildren(mc, "gotoAndStop", [3]);

Upvotes: 1

Related Questions