Things You'll Need:
- A working installation of Flash
-
Step 1
Before you can control a movie clip's animation, you'll need a movie clip to control. If you haven't already, create a new movie clip type symbol and create an animation on the movie clip's timeline (not on the main stage).
-
Step 2
To prevent the movie clip from beginning to play the moment that your Flash movie loads, insert an ActionScripted stop on the first frame of the movie clip's timeline.
-
Step 3
Now return to your main stage and primary timeline. On the main stage, make sure that your animated movie clip is selected; then look at the Properties panel at the bottom of the screen. In the "Instance Name" box below the dropdown listing the type of clip behavior, type in a unique name for the symbol. In this example, the clip is named "square".
-
Step 4
On the main stage, create a new symbol. We're going to use this symbol as a controller; there are many ways to control the playback of another movie clip, from using ClipEvents that check for various actions to "on" handlers that only react with direct action, but the easiest and most common way is to trigger the action of one movie clip when another is clicked, prompting playback on user action. In this example, the main movie clip will begin to play when the trigger movie clip is clicked.
-
Step 5
Right-click on the the new movie clip and select "Actions" to open the Actions Panel for the controller clip.
-
Step 6
In Normal Mode (not Expert Mode), navigate through the left-hand tree by clicking Actions->Movie Controls->on. When you double-click "on", an "on (release)" will automatically appear in the script area, complete with requisite opening and closing brackets. You'll also see a list of checkboxes that allow you to choose one or more events that will trigger an action. "Release" is the most common, as it triggers the action not when the user clicks down on the mouse button, but when they release the button after clicking. "Press" triggers the action immediately on clicking. "Release Outside" triggers the action after the user clicks, drags, and lets go of the mouse outside of the symbol's area. "Key Press" triggers the action when the user clicks on the specified key. "Roll Over" triggers the action after the user moves the mouse over the symbol without clicking. "Roll Out" triggers the action after the user moves the mouse over the symbol without clicking, then moves the mouse away. "Drag Over" and "Drag Out" are similar to "Roll Over" and "Roll Out", but occur only when the user has clicked and held the mouse while moving it. For this example, leave the "Release" checked and nothing else.
-
Step 7
Now that the event that triggers action is defined, the next step is to define the action being triggered. With your "on (release)" selected, navigate through the left-hand tree; click Actions->Movie Controls->goto. This will insert a gotoAndPlay script, with the default set to the current scene and first frame. GotoAndPlay scripts do just that: go to the scene and frame defined, and play from that point. You can also use gotoAndStop to jump to a frame and stop there. GotoAndPlay scripts can also be modified from the basic use to control other timelines beyond the main one.
-
Step 8
In order to make the gotoAndPlay script act on the animated movie clip instead of the main timeline, you have to tell Flash where to look before enacting the actions in the script. For this, you'll need to switch to Expert Mode (the blue button at the top right of the scripts area) so you can type these directions manually.
-
Step 9
The "directions" referred to are actually a path to the location where Flash should gotoAndPlay, starting with "_root". "_root" tells Flash to go all the way up to the top level, then look for the locations in the path from there. All path locations are separated by a period. Since, for this example, Flash is supposed to gotoAndPlay a certain frame on the movie clip named "square", the gotoAndPlay script would be modified to say "_root.square.gotoAndPlay(1);". Now Flash knows to go to the top level, look for a movie clip named "square" and go to frame one of that movie clip's timeline (instead of the main stage's timeline) and play from there.
-
Step 10
Since the movie clip has a stop on the first frame of its timeline, using "_root.square.gotoAndPlay(1);" does nothing, as the stop halts playback right there. To make it jump away from the first frame and play continuously until the end or until the next scripted stop, just change the frame number to the next one: "_root.square.gotoAndPlay(2);".
-
Step 11
Return to your main stage and publish a preview to see how it works. When you click on the controller movie clip, the animated movie clip should begin to play.









Comments
Beveronius said
on 2/15/2008 very helpful - thank you