Introduction to ActionScript3

Get Adobe Flash player

Refresh the page to see the ball bounce from the top, then play the last bit over and over.

We created a movie with a ball that moves. We added ActionScript to make the ball stop.

Now we will make the ball start over in a frame other than 1.

  1. With the last frame of the actionscript layer selected open the Actions window. (F9 or select Windows, Actions from the menu.)add an actionscript layer
  2. Type the code exactly as shown below: (Notice that the code turns blue if typed correctly.)
  3. When the movie gets to the last frame, it will go back to 30 instead of frame 1. You will only see the ball move from the top to the bottom once, then it will replay the last few frames

Experiment: Move the keyframe with the command gotoAndPlay(30); to the first frame. Only the last bit of animation will play. Try other positions cor the code and other frames.

Next: Instead of stopping, we will make the movie start from a frame other than 1.

Download the finished movie

NEXT: Code Snippets