我将第50帧命名为_foo
(在IDE中)。
我可以随时追踪this._currentFrame
(并获得一个数字)。
我可以gotoAndPlay("_foo");
。
但是如何判断电影播放时当前帧是否为_foo
?
这可能吗?
答案 0 :(得分:2)
在ActionScript 2中,无法访问当前帧的名称/标签(在ActionScript 3中添加了此功能)。
但是,您可以使用以下代码确定播放期间的当前帧编号:
// This is the frame number we want to look out for.
var targetFrame : Number = 50;
// Crate an onEnterFrame function callback, this will be
// called each time the current MovieClip changes from one
// frame to the Next.
onEnterFrame = onEnterFrameHandler;
/**
* This function is called each time the MovieClip enter a
* new frame during playback.
*/
function onEnterFrameHandler() : Void
{
trace("_currentframe: " + _currentframe);
if (_currentframe == targetFrame)
{
trace("Playhead is at Frame: " + _currentframe);
// Stop playback and remove the onEnterFrame callback.
stop();
onEnterFrame = null;
}
}
如需进一步阅读,请务必查看MovieClip.onEnterFrame
的Adobe livedocs条目