我如何知道 MovieClip 何时放置在舞台上完成播放?

发布于 2024-09-30 17:25:16 字数 177 浏览 1 评论 0原文

MovieClip(mcName).play();
MovieClip(mcName).addEventListener(??????, myStopFunction);

或者你对比赛结束的了解有何不同?

MovieClip 是一个外部文件,根据需要加载到 swf 中。

MovieClip(mcName).play();
MovieClip(mcName).addEventListener(??????, myStopFunction);

Or how differently you can learn about the end of play?

MovieClip is an external file and loaded into the swf as needed.

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

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

发布评论

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

评论(4

苍景流年 2024-10-07 17:25:16

当我有自定义动画并想知道何时完成时,我会从动画的最后一帧调度自定义事件。通常一个 Event.COMPLETE 就可以了。

在 myAnimation MovieClip 的最后一帧中,我执行以下操作:

this.dispatchEvent(new Event(Event.COMPLETE));
stop();

然后在主代码中,我监听将侦听器添加到该 evnet:

myAnimation.addEventListener(Event.COMPLETE, animationEndHandler);

When I have a custom animation and want to know when finishes I use to dispatch a custom event from the last frame of the animation. Usually an Event.COMPLETE will do.

In the last frame of the myAnimation MovieClip I do:

this.dispatchEvent(new Event(Event.COMPLETE));
stop();

Then in the main code I listen add listener to that evnet:

myAnimation.addEventListener(Event.COMPLETE, animationEndHandler);
末骤雨初歇 2024-10-07 17:25:16

几乎像 @daniel.sedlacek 答案,但没有时间线代码:

var mc : MovieClip = new $TestMovieClip();          
mc.addEventListener(Event.COMPLETE, function() : void {
    trace("COMPLETE");
});
mc.addFrameScript(mc.totalFrames-1, function() : void {
    mc.dispatchEvent(new Event(Event.COMPLETE));                
});
mc.play();

Almost like @daniel.sedlacek answer, but without timeline code :

var mc : MovieClip = new $TestMovieClip();          
mc.addEventListener(Event.COMPLETE, function() : void {
    trace("COMPLETE");
});
mc.addFrameScript(mc.totalFrames-1, function() : void {
    mc.dispatchEvent(new Event(Event.COMPLETE));                
});
mc.play();
幸福%小乖 2024-10-07 17:25:16

对于具有多个场景的 MovieClip,仅检查 currentFrametotalFrames 是不够的。您还必须检查它是否在最后一个场景。

function isAtLastFrame(mc:MovieClip):Boolean
{
  return currentScene.name == mc.scenes[mc.scenes.length - 1].name && currentFrame == currentScene.numFrames;
}

Only check currentFrame and totalFrames is not enough for a MovieClip that has multiple scenes. You must also check if it is at the last scene.

function isAtLastFrame(mc:MovieClip):Boolean
{
  return currentScene.name == mc.scenes[mc.scenes.length - 1].name && currentFrame == currentScene.numFrames;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文