Introduction to ActionScript3

Get Adobe Flash player

Refresh the page to see the ball bounce once, then stop.

We created a movie with a ball that moves. Now we will add ActionScript to make the ball stop.

  1. Add a new layer and name it actionscript
  2. Add a keyframe in the last frame of the actionscript layer.
    add an actionscript layer
  3. With the last frame of the actionscript layer selected open the Actions window. (F9 or select Windows, Actions from the menu.)
  4. Type the code exactly as shown below:
         stop();
    
  5. When the movie gets to the last frame, it will stop. You will only see the ball move from the top to the bottom once.

Experiment: Move the keyframe with the command stop(); to the first frame. The ball will not bounce at all. Try other positions.

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

Download the finished movie

NEXT: Play!