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?
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