Introduction to ActionScript3
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.
- Add a new layer and name it actionscript
- Add a keyframe in the last frame of the actionscript layer.
- With the last frame of the actionscript layer selected open the Actions window.
(F9 or select Windows, Actions from the menu.)
- Type the code exactly as shown below:
- 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