Accessibility

TechNote (Archived)

How to prevent a Flash movie from looping

The Macromedia Flash Player is designed to continuously loop a Flash movie. As soon as the last frame has finished playing, the Player starts again at the first frame. This is a feature of Flash, based on developers' requests. However, if you wish to construct a movie that will play only once, several methods will stop the Flash movie from looping.

Stopping the movie using ActionScript

The simplest way to stop a movie from looping is to add aStop action to the last keyframe of the movie.

  1. Select the last frame of the timeline.



    Note: To develop best scripting practices always add an 'actions' layer. Place all frame actions in keyframe in that layer.
  2. In the Actions panel (Window > Actions), verify that the correct Frame is selected.

  3. Click in the Script pane of the Actions panel, and type the following comment:

    // Stops the playhead at Frame 1.

    Press Enter (Windows) or Return (Macintosh).
  4. Type stop(); to add the stop action.

Movie clips, being just another timeline, also loop by default. This technique can also be used to stop a movie clip from looping, or to "park" a movie clip in a specific frame. See How to 'park' a movie clip so it can be preloaded and reused (TechNote tn_14404) for more information.

Stopping the movie using HTML tags

The Flash movie loop can also be disabled in the tags used to embed the movie in an HTML page. This allows looping to be turned back on without editing the Flash movie itself.

  1. Choose File > Publish Settings.
  2. Choose the HTML tab of the Publish Settings dialog and deselect the Loop option.
  3. Publish the movie (File > Publish).

    When the page is viewed in the browser the Flash movie will stop on the last frame. However, movie clips inside the main movie will continue to loop, provided they do not contain stop actions.

    The movie can be restarted by:
    • Reloading the HTML page.
    • Right-clicking (Windows) or Control-clicking (Macintosh) and choosing Play from the context menu.
    • Adding a gotoAndPlay action to a button the user can click that sends the playback head to the first frame of the movie.

Additional Information


For information on controlling the number of times a Flash movie loops, refer to How to loop over some frames a given number of times (TechNote tn_14023).

AlertThis content requires Flash

To view this content, JavaScript must be enabled, and you need the latest version of the Adobe Flash Player.

Download the free Flash Player now!

Get Adobe Flash Player

Creative Commons License

Search Support


Document Details

ID:tn_14189
Browser:Chrome
Internet Explorer
Netscape
Opera
Safari
Firefox

Products Affected:

flashplayer