views:

20

answers:

1

I name frame 50 "_foo" (in the IDE)

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

I can gotoAndPlay("_foo");

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

Is this possible?

+1  A: 

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

JonnyReeves
yeah, unfortunately the frame number is useless to me in this context. However, I'm simply creating my own property called _frameName and assigning a value to it at the appropriate frame and then testing to see if that's the value when onEnterFrame. Works just as well.
Dr.Dredel