Creating Interaction with ActionScript > Controlling movie playback > Jumping to a frame or scene

 

Jumping to a frame or scene

To jump to a specific frame or scene in the movie, you use the goto action. When the movie jumps to a frame, you can choose parameters that either play the movie from the new frame (the default) or stop at the frame. In expert mode, the goto action is listed as two actions in the Actions toolbox: gotoAndPlay and gotoAndStop. The movie can also jump to a scene and play a specified frame or the first frame of the next or previous scene.

 
To jump to a frame or scene:

1

Select a frame, button instance, or movie clip instance to which you will assign the action.

2

Choose Window > Actions to display the Actions panel if it is not already visible. If the Actions panel is not in normal mode, choose Normal Mode from the View Options pop-up menu.

3

In the Actions toolbox, click the Actions category and then click the Movie Control category, and double-click the goto action.

Flash inserts the gotoAndPlay action in the Script pane.

4

To keep playing the movie after the jump, leave the Go To and Play option (the default) selected in the parameters pane. To stop the movie after the jump, select the Go To and Stop option.

5

In the Scene pop-up menu in the parameters pane, specify the destination scene.

If you select Next or Previous, the playhead jumps to the first frame in the next or previous scene. If you select the current scene or a scene that you have named, you must provide a frame for the playhead to jump to.

6

In the Type pop-up menu in the parameters pane, choose a destination frame:

Next Frame or Previous Frame sets the destination frame to the next or previous frame.

Frame Number, Frame Label, or Expression allows you to specify a frame. An expression is any part of a statement that produces a value, such as 1 + 1.

7

If you chose Frame Number, Frame Label, or Expression in step 6, in the Frame parameter box enter the frame number, the frame label, or an expression that evaluates to a frame number or label.

The following action jumps the playhead to frame 50, where play continues:

gotoAndPlay(50);

The following action jumps the playhead to a frame that is five frames ahead of the frame that contains the action:

gotoAndStop(_currentframe + 5);

For more information on writing expressions, see Using operators to manipulate values in expressions.

For more information about using the Actions panel in normal and expert modes, see Creating Interaction with ActionScript.