开发者

is it possible to access the NAME property of a frame in Actionscript 2.0?

I name frame 50 _foo (in the IDE).

I can trace this._currentFrame at any time (and get a number).

开发者_Python百科

I can gotoAndPlay("_foo");.

But how can I find out if the current frame IS _foo as the movie plays?

Is this possible?


In ActionScript 2 there is no way to access the Name / Label of the current frame (this feature was added in ActionScript 3).

However, you could use the following code to determine the current frame number at during playback:

// 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;
    }
}

For further reading, be sure to check the Adobe livedocs entry for MovieClip.onEnterFrame

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜