Is there a way to listen for the completion of a MovieClip playing?

倾然丶 夕夏残阳落幕 提交于 2019-12-12 01:32:51

问题


I want to execute a function upon completion of a MovieClip's animation. That is, I would command it to play() or gotoAndPlay(). I don't know of any listener that I can attach to the MovieClip with the "addEventListener()" command. Have any idea I can do?


回答1:


You can use the addFrameScript method, as shown in this post to dispatch a custom event when the last frame is reached.




回答2:


stage.addEventListener(Event.ENTER_FRAME, onCheckAnimationComplete)

function onCheckAnimationComplete(e:Event)
{
    if(animation.currentFrame==animation.totalFrames)
    {
        //TODO call a function
    }
}


来源:https://stackoverflow.com/questions/3367443/is-there-a-way-to-listen-for-the-completion-of-a-movieclip-playing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!