因此,正如我从您的图像中看到的那样,您实际上需要检查 的帧player.totoswing.currentFrame
,但在执行此操作之前,请确保totoswing
MovieClip 存在于播放器中。currentFrame
如果玩家不是 5,它可能不存在。
因此,要检查动画的当前帧,请执行以下操作:
if(player.totoswing)
trace(player.totoswing.currentFrame);
如果您想在最后一帧停止它,您可以在stop()
totoswing MovieClip 的最后一帧添加一个脚本。
如果您想知道 totoswing 动画何时结束,您可以执行以下操作:
if(player.totoswing)
{
player.totoswing.addEventListener(Event.ENTER_FRAME, onTotoSwingFrame);
player.totoswing.play();
}
function onTotoSwingFrame(e:Event):void
{
if(e.target.currentFrame == e.target.totalFrames)
{
//animation has ended
e.target.removeEventListener(Event.ENTER_FRAME, onToToSwingFrame);
// do whatever you want. ex. play the idle state
}
}
ENTER_FRAME
我们首先为 MovieClip 的事件添加一个侦听器player.totoswing
,以便它在每次前进一帧时触发一个事件。在事件处理程序(onTotoSwingFrame
)中,我们检查player.totoswing
当前帧是否等于其总帧数,如果是,我们停止播放并且我们知道动画已经完成。我们不再需要ENTER_FRAME
监听器,所以我们将其移除。