Flash animation -- how can I stop looping and remain on the last image/frame?

30.9k Views Asked by At

I am new to Flash and cannot get an FLA animation to stop on the last frame. I have used the "stop()" command in Actionscript, but this command either (i) stops the animation and goes to a blank white frame (possibly the first frame of the animation) if I insert a Blank Keyframe, or (ii) loops anyway if I insert a regular Keyframe.

I am working with a rebuilt FLA file (i.e., decompiled SWF file) on the latest version of Flash. In addition to Actionscript, I have tried adjusting the Publish Settings (e.g., unchecking "Loop" and setting the Flash version to 7 or 8) and editing the embed parameters (as suggested in another answer on Stack), however neither of these efforts seems to make a difference.

Any help would be appreciated -- thanks!

3

There are 3 best solutions below

3
On

Are there any movieclips on the stage?

You should know that each movieclip has it's own timeline and thus to stop that particular movieclip from animating, stop(); should be placed within the appropriate keyframe in that movieclip's timeline..

0
On

There are a couple of ways to do it. The easiest way (like "user559142" suggested) is to just put a "stop()" command on the last frame of that MovieClip's timeline. Just add it to the last frame.

Unfortunately MovieClips don't dispatch a COMPLETE event when they have reached their last frame; a shortcoming of the platform, in my mind. A more heavyweight way to ensure that your MovieClip stops on the last frame is to listen for the ENTER_FRAME event, and to call stop() when the current frame is equal to the last frame, like so:

your_movie_clip.addEventListener(Event.ENTER_FRAME, function(e:Event):void 
{
   if (your_movie_clip.currentFrame == your_movie_clip.totalFrames)
   {
      your_movie_clip.stop(); 
   }
});

A note, however, is that if you uncheck "looping" you will only see the content not looping when the SWF is published (and viewed) in an HTML wrapper, and even then only if the content you're trying to stop from looping appears on the main timeline. If you're just previewing within the authoring environment, or your content has their own timelines where you're trying to prevent looping, you won't see that behavior.

0
On

Please following code

<param name='loop' value='false' />
<object type='application/x-shockwave-flash' data='sourcefile' width='300' height='120' loop='false'>

This works perfectly