开发者

How to resume animation from last position irrespective of whether I pause it on main timeline animation or child/grandchild MC animation?

开发者 https://www.devze.com 2023-04-05 06:32 出处:网络
I have found a generic recursive loop that stops/pauses all child movieclips. If I change stop to play in the code, it plays all child movieclips simultaneously. I want it to resume only one animation

I have found a generic recursive loop that stops/pauses all child movieclips. If I change stop to play in the code, it plays all child movieclips simultaneously. I want it to resume only one animation at a time. I want a generic recursive loop that resumes animation from last position (position it was paused) irrespective of whether I have paused on the main timeline animation or animations within child movieclips or animations within grandchild movieclips. (I have animations on main timeline, animations within lastFrame MC of maintimeline, and again within last frame MC of child's timeline). How can I do this? I am new to f开发者_JS百科lash, so please simple explanation/suggestions. Thanks.

btnStart.addEventListener(MouseEvent.CLICK, startMotion);

function startMotion(evt:MouseEvent):void {

    playAllChildMovieClips(stage);

}

function playAllChildMovieClips(displayObject:DisplayObjectContainer):void{

    var numChildren:int = displayObject.numChildren;

    for (var i:int = 0; i < numChildren; i++) {

        var child:DisplayObject = displayObject.getChildAt(i);

        if (child is DisplayObjectContainer) {
            if (child is MovieClip) {

                MovieClip(child).play();

                }
                playAllChildMovieClips(DisplayObjectContainer(child));
            }
        }

} Probably I am not good at explaining things. So, i am rephrasing my question and if you want, you can download and see my files. I have parent swf which has a resume/play button. Parent swf loads a child swf. Child swf has animations with voice over several levels deep. When I use the above code, stop button stops animations at all levels but resume/play button resumes as well as rewinds animations and voice overs. I would like resume button to resume animation not rewind it from the beginning? If I still don't make sense, please see the files provided in the links:http://www.mediafire.com/?ks3ibqt9kcpx4, http://www.mediafire.com/file/8rncs0c8chy8a6i/clip4.swf, http://www.mediafire.com/file/ea1gm0za6l6kva0/clip4.fla. Thanks


Just make a new function that stops the movieclips. The difference between the functions is that the first one uses play() and the other uses stop(). It sounded that your original function worked this way.

playAllChildMovieClips(targetMovieclip); // using MovieClip(child).play();

stopAllChildMovieClips(targetMovieclip); // using MovieClip(child).stop();

btnStart.addEventListener(MouseEvent.CLICK, startMotion);
btnStop.addEventListener(MouseEvent.CLICK, stopMotion);

function startMotion(evt:MouseEvent) : void
{

    playAllChildMovieClips(stage);

}

function playAllChildMovieClips(displayObject:DisplayObjectContainer):void{

    var numChildren:int = displayObject.numChildren;

    for (var i:int = 0; i < numChildren; i++) {

        var child:DisplayObject = displayObject.getChildAt(i);

        if (child is DisplayObjectContainer) {
            if (child is MovieClip) {

                MovieClip(child).play();

                }
                playAllChildMovieClips(DisplayObjectContainer(child));
            }
        }
}



function startMotion(evt:MouseEvent) : void
{

    stopAllChildMovieClips(stage);

}

function stopAllChildMovieClips(displayObject:DisplayObjectContainer):void{

    var numChildren:int = displayObject.numChildren;

    for (var i:int = 0; i < numChildren; i++) {

        var child:DisplayObject = displayObject.getChildAt(i);

        if (child is DisplayObjectContainer) {
            if (child is MovieClip) {

                MovieClip(child).stop();

                }
                stopAllChildMovieClips(DisplayObjectContainer(child));
            }
        }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消