如何从上一个位置恢复动画,无论我是在主时间轴动画还是子/孙 MC 动画上暂停它?

发布于 2024-12-05 05:04:34 字数 1418 浏览 2 评论 0原文

我发现了一个通用的递归循环,可以停止/暂停所有子影片剪辑。如果我在代码中将停止更改为播放,它会同时播放所有子影片剪辑。我希望它一次只恢复一个动画。我想要一个通用的递归循环,它可以从最后一个位置(暂停的位置)恢复动画,无论我是否在主时间线动画或子影片剪辑中的动画或孙子影片剪辑中的动画上暂停。 (我在主时间轴上有动画,在主时间轴的最后一帧 MC 内有动画,在子时间轴的最后一帧 MC 内也有动画)。我该怎么做?我是闪存新手,所以请简单的解释/建议。谢谢。

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));
            }
        }

} 也许我不擅长解释事情。因此,我正在重新表述我的问题,如果您愿意,您可以下载并查看我的文件。我有父 swf,它有一个恢复/播放按钮。父 swf 加载子 swf。儿童 swf 的动画具有多个深度的语音。当我使用上面的代码时,停止按钮会停止所有级别的动画,但恢复/播放按钮会恢复并倒回动画和画外音。我想要恢复按钮来恢复动画而不是从头开始倒带?如果我仍然不明白,请参阅链接中提供的文件:http://www.mediafire.com/?ks3ibqt9kcpx4,http://www.mediafire.com/file/8rncs0c8chy8a6i/clip4.swf, http://www.mediafire.com/file/ea1gm0za6l6kva0/clip4.fla 。谢谢

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 flash, 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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

咽泪装欢 2024-12-12 05:04:34

只需创建一个停止影片剪辑的新函数即可。这两个函数的区别在于第一个函数使用 play(),另一个函数使用 stop()。听起来你原来的功能是这样工作的。

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));
            }
        }
}

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));
            }
        }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文