0
votes

I'm having same issue exactly explained in this forum post How to stop all child movieclips inside a movieclip in AS3?

Except my requirement is When user click the pause button current frame holding movie clip child element should gotoAndStop and 25 frame.

Also I'm using a timer function so when user click pause button timer should be stopped. This actually working when I add the following code myTimer.stop(); however if I clicked the play button I put this one myTimer.start();. The issue is from myTimer.start(); function it's actually starting the timer all over again but I need to resume the timer.

Could any help me out of these issues. ASAP

3
What are you using the timer for? And you want to have the currentcount to not reset?putvande
I'm using timer for move to the nextFrameFR STAR
Timer unfortunately does not have a pause / resume ability so you need to keep a variable when you stop the timer and start it again.putvande
could you please instruct me how to do that. I'm very new to AS3FR STAR
I have posted an answer. See if you can use it.putvande

3 Answers

1
votes

To stop all your child movieclips you could use the code provided in that answer you linked to in your question:

yourButton.addEventListener(MouseEvent.CLICK, onClick);

function onClick(e:MouseEvent):void {
    stopAllClips(yourMovieClip);
}

function stopAllClips(mc:MovieClip):void
{
    var n:int = mc.numChildren;
    for (var i:int=0;i<n;i++)
    {
        var clip:MovieClip = mc.getChildAt(i) as MovieClip;
        if (clip && clip.name != 'mc_2')
            clip.gotoAndStop(2);
    }
}

In order to 'resume` your timer you need to keep a variable so you can 'resume' again. Something like this:

var tempTimerCount:int = 0;
var timer:Timer = new Timer(1000);
timer.start();

And then when you want to stop:

tempTimerCount += timer.currentCount;
timer.stop();

And after start and you want to have the value of that timer you need to get the timer.currentCount + tempTimerCount;

Hope it helps.

2
votes

You can use recursion:

function stopAll(parent:DisplayObjectContainer){
    for(var i:int = 0; i < parent.numChildren; i++){
        var child = parent.getChildAt(i);        
        if(child.hasOwnProperty('stop')){
            child.stop();
        }
        if(child.hasOwnProperty('numChildren')){
            stopAll(child);
        }
    }
}

To assign to the button:

yourButton.addEventListener(MouseEvent.CLICK, onClick)

function onClick(e:MouseEvent){
    stopAll(youMainMovieClip);
}
0
votes

Try this code it works 100%

Put this code in your main timeline and called using mouse event MovieClip_name.stopAllClips();

MovieClip.prototype.stopAllClips = function():void { var mc:MovieClip = this; var n:int = mc.numChildren; mc.stop(); for (var i:int=0; i<n; i++) { var clip:MovieClip = mc.getChildAt(i) as MovieClip; if (clip) { clip.stop(); clip.stopAllClips(); } } }