AS 3.0 有即玩即死功能吗?

发布于 2024-12-29 09:04:29 字数 80 浏览 4 评论 0原文

AS 3.0中是否有任何函数可以播放MovieClip,然后在播放后执行removeChild()?我不想停止()它,我只是想把孩子从舞台上移走。

Is there any function in AS 3.0 that plays a MovieClip and then does removeChild() after it has been played? I don´t want to stop() it i just want to remove the child from stage.

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

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

发布评论

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

评论(2

无声无音无过去 2025-01-05 09:04:29

作为 Sr.Richie 建议的代码示例,以下是所需内容:

在要播放和删除的 MC 内部,添加此帧代码:

addEventListener(Event.ENTER_FRAME, function (e:Event):void {
   if(currentFrame==totalFrames) {
      removeEventListener(Event.ENTER_FRAME, arguments.callee);
      parent.removeChild(this);     
   }
}

注意,我尚未测试此代码,但这是总体思路。

As a code example, suggested by Sr.Richie, here is what is required:

Inside the MC to play and remove, add this frame code:

addEventListener(Event.ENTER_FRAME, function (e:Event):void {
   if(currentFrame==totalFrames) {
      removeEventListener(Event.ENTER_FRAME, arguments.callee);
      parent.removeChild(this);     
   }
}

Note I haven't tested this code, but it's the general idea.

戴着白色围巾的女孩 2025-01-05 09:04:29

不,没有内置方法可以做到这一点。

但是您可以让您的对象扩展 MovieClip,并创建一个由 ENTER_FRAME 事件触发的自定义方法来检查是否到达最后一帧,然后将它们从父级中删除

No, there's no built-in method to do it.

But you can let your objects extend MovieClip, and create a custom method triggered by an ENTER_FRAME event to check if the last frame is reached, and remove them from the parent then

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