Online Test Banks
Score higher
See Online Test Banks
Learning anything is easy
Browse Online Courses
Mobile Apps
Learning on the go
Explore Mobile Apps
Dummies Store
Shop for books and more
Start Shopping

How to Use gotoAndPlay() and gotoAndStop() in Flash CS5 ActionScript

To loop a Adobe Flash Creative Suite 5 movie or to send the playhead to a different point on the Flash CS5 timeline, you can tell your movie to jump forward or backward to a specific frame with one of two variations of the goto statement: gotoAndPlay() and gotoAndStop().

Each of these two statements requires a frame name or number so that Flash Player knows where to send the playhead. When placed on a frame, these actions send the playhead forward or backward to the specified frame and stop, or they resume playback from that point.

To use gotoAndStop, follow these steps:

  1. On the Actions layer, select and create a new keyframe at frame 23.

  2. Choose Window→Actions to open the Actions panel.

  3. Click the plus sign and choose flash.display→MovieClip→Methods→gotoAndStop.

  4. In the Object field, target the current timeline by typing this in the Object text box. Enter 1 in the Frame text box and make sure the Scene text box is empty.

    The statements should now read

    import flash.display.MovieClip;
  5. Choose Control→Test Movie to preview your movie.

    The tween plays and jumps to the first frame, where it stops.

Follow these steps to use gotoAndPlay():

  1. Create a new keyframe at frame 22 on the Actions layer and launch the Actions panel with the new keyframe selected.

  2. Click the plus sign and choose flash.display→MovieClip→Methods→gotoAndPlay.

    In the Object text box, have the timeline refer to itself by typing this.

  3. Enter 5 in the Frame text box and make sure the Scene text box is empty (see Figure 7-5).

    The actions should now read

    import flash.display.MovieClip;
  4. Choose Control→Test Movie to preview your movie.

    The animation plays until frame 22 and loops between frames 5 and 22.

  • Add a Comment
  • Print
  • Share
blog comments powered by Disqus

Inside Sweepstakes

Win $500. Easy.