How to Create a Pause in a Flash Movie

How to Create a Pause in a Flash Movie thumbnail
Use ActionScript to pause and stop Flash movies.

Flash supports several ways to pause a movie (stop movie playback). However, most designers usually have only two reasons to intentionally interrupt movie playback: either to stop playback to wait for user interaction, such as a mouse click, or to pause playback temporarily for effect---allowing the user time to take in (or notice something on) a particular screen. Both types of pauses are easily achieved with simple, easy-to-write scripts.

Things You'll Need

  • Adobe Flash CS3 or later
Show More

Instructions

  1. Stopping a Movie to Wait for User Interaction

    • 1

      Open the Flash FLA movie in which you want to create a pause.

    • 2

      Go to the frame on the scripts layer in the Timeline where you want to create a pause. (If your movie doesn't have a layer for scripts, create one: Click the "New Layer" button [the page icon in the lower-left corner of the Timeline panel]. Double click the layer name and rename the layer. Most designers name their scripts layer "Actions" or "Scripts.") Right click the frame and choose "Insert Keyframe" from the fly-out menu.

    • 3

      Right click the new keyframe and choose "Actions" from the fly-out menu. This opens the Actions panel. Type the following script into the right pane of the Actions panel:

      stop();

    • 4

      Test the movie. It stops playing on the frame in which you inserted the script. Keep in mind that this script stops the movie cold. It can't do anything else unless you provide the user a way out, such as a button that jumps the movie to the next frame, scene or some other frame in the Timeline. Usually, you would create several buttons or a menu in this frame.

    Pausing a Movie for Effect

    • 5

      Open the Flash FLA movie in which you want to create a pause.

    • 6

      Go to the frame on the scripts layer in the Timeline where you want to create a pause. (If your movie doesn't have a layer for scripts, create one: Click the "New Layer" button [the page icon in the lower-left corner of the Timeline panel]. Double click the layer name and rename the layer. Most designers name their scripts layer "Actions" or "Scripts.") Right click the frame and choose "Insert Keyframe" from the fly-out menu.

    • 7

      Right click the new keyframe and choose "Actions" from the fly-out menu. This opens the Actions panel.

    • 8

      Type the following script into the right pane of the Actions panel:

      this.stop();

      var timelinePause:Timer = new Timer(5000, 1);
      timelinePause.addEventListener(TimerEvent.TIMER, timerHandler);
      timelinePause.start();

      function timerHandler(evt:Object):void {
      this.play();
      }

      This script stops the movie and creates a timer variable that starts the movie again after five seconds. You can change the number of seconds the movie pauses by changing the number "5000" in the second line of the script. Seconds are measured in milliseconds. So, for example, to change the pause to 10 seconds, change "5000" to "10000."

    • 9

      Test the movie. It should pause in the frame where you inserted the script. If it doesn't, check your script.

Tips & Warnings

  • You can also use the pause script above to pause playback at the end of the movie and then start the movie over again. Simply add the script to the last frame in the movie.

  • The "stop();" action works in all versions of Flash.

  • If you have any other scripts in your movie, they must be written and constructed correctly and all instance names must be defined properly in the scripts. Flash Player usually ignores "stop();" actions when it encounters script errors anywhere on the Timeline.

Related Searches:

References

  • Photo Credit stop ahead image by leemarusa from Fotolia.com

Comments

  • Ronny Syvertsen Feb 03, 2011
    Never mind... Figured it out :-)
  • Ronny Syvertsen Feb 03, 2011
    Hello. I found this script to be just what I was looking for. However I need to pause several frames in my timeline. When adding this script on another frame I get the following error: 1151: A conflict exists with definition timelinePause in namespace internal. 1021: Duplicate function definition. Please help :-) Sincerely Ronny

You May Also Like

Related Ads

Featured