2
MovieClip(mcName).play();
MovieClip(mcName).addEventListener(??????, myStopFunction);

Or how differently you can learn about the end of play?

MovieClip is an external file and loaded into the swf as needed.

Phonon
  • 12,549
  • 13
  • 64
  • 114
user499596
  • 21
  • 1
  • 6

4 Answers4

2

When I have a custom animation and want to know when finishes I use to dispatch a custom event from the last frame of the animation. Usually an Event.COMPLETE will do.

In the last frame of the myAnimation MovieClip I do:

this.dispatchEvent(new Event(Event.COMPLETE));
stop();

Then in the main code I listen add listener to that evnet:

myAnimation.addEventListener(Event.COMPLETE, animationEndHandler);
daniel.sedlacek
  • 8,129
  • 9
  • 46
  • 77
1

Almost like @daniel.sedlacek answer, but without timeline code :

var mc : MovieClip = new $TestMovieClip();          
mc.addEventListener(Event.COMPLETE, function() : void {
    trace("COMPLETE");
});
mc.addFrameScript(mc.totalFrames-1, function() : void {
    mc.dispatchEvent(new Event(Event.COMPLETE));                
});
mc.play();
OXMO456
  • 3,558
  • 2
  • 25
  • 35
0

Only check currentFrame and totalFrames is not enough for a MovieClip that has multiple scenes. You must also check if it is at the last scene.

function isAtLastFrame(mc:MovieClip):Boolean
{
  return currentScene.name == mc.scenes[mc.scenes.length - 1].name && currentFrame == currentScene.numFrames;
}
Yang Bo
  • 3,586
  • 3
  • 22
  • 35