10.2. Preventing the Movie from Looping

Problem

You want to prevent a movie from looping back to the beginning when it reaches the last frame.

Solution

Add a stop( ) action to a keyframe in the final frame, or set the HTML loop parameter/attribute to false.

Discussion

You can prevent a movie from looping by using a stop( ) action or by using HTML attributes to control the movie.

To use a stop( ) action, complete the following steps:

  1. If you haven’t already done so, add a layer for your ActionScript code to the timeline. Give the layer a label of Actions.

  2. Insert a keyframe in the Actions layer at the final frame within the timeline. To add a keyframe, choose Insert → Keyframe, or press F6.

  3. Select the keyframe that you just added, and open the Actions panel by pressing F9.

  4. Add the stop( ) action by typing it into the Script pane.

To use HTML to prevent looping, create/change the loop parameter in the <object> tag, so that its value is false (e.g., <param name="loop" value="false">). Likewise, set the <embed> tag’s loop attribute to false. As noted in Recipe 10.1, generally, using a stop( ) action is preferred over relying on HTML attributes.

Get Flash 8 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.