Creating A PLAY Button with ActionScript 3.0
Timeline Actions
Before we really get going, it's important to know we are only controlling the main timeline with these instructions. If you need to control individual MovieClip timelines, you'll have to continue the lessons.
Let's get your movie to STOP on the first frame. We are going to do this by putting some code on a keyFrame. First, create a new layer at the very top and name it actions. It's a good habit to create a unique layer just for actions:
Make certain you have the first frame of the new actions layer selected (like in the picture above), then bring up the Actions window (the keyboard shortcut is F9)
- Make certain the top left corner says Actions-Frame (select Frame One on the timeline if not)
- Disable Script Assist
- Hide the builder panel on the left
This is what my Actions window looks like all cleaned up:
Now we'll use the stop method to stop the timeline on Frame 1. Just type stop(); in the Actions window:
If you test the movie now, it should stop on frame one - Wow, you're a programmer! Have a look at the timeline again. The strange little a indicates there is ActionScript "on" Frame 1 of the actions layer: