问题
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