Take a look at the example movie 06clipcommunication.fla to see what this looks like before trying to build it yourself.
Create a new Flash movie. Make a movie clip that has 15 frames of animation. Name it “cog”.
Inside the movie clip, place a stop() script on the first frame. This prevents it from animating all by itself. Instead, we will control its animation through ActionScript.
On the 15th frame of the movie clip, place the following script:
_parent[clipToTell].nextFrame();
gotoAndStop(1);
This code does two things. First, it tells a sibling movie clip with the name stored in the variable clipToTell that it should advance to the next frame. Second, it sends itself back to the first frame to start again.
Now we just have to define the variable clipToTell. We’ll do this in the movie clip script, so exit the editing of the “cog” movie clip and return to the main timeline. Place an instance of the “cog” movie clip in the work area and name it “cog1″.
Now attach a movie clip script to it. Here is the script:
onClipEvent (load) {
clipToTell = “cog2″;
}
onClipEvent (enterFrame) {
nextFrame();
}
The first thing that happens when the movie clip starts is that the variable clipToTell is set to “cog2″. This means that when the movie clip gets to frame 15, it uses the previous script in step 3 to tell “cog2″ to advance one frame.
The onClipEvent (enterFrame) handler is used to advance this movie clip by one frame for each main movie frame.
Taken From: Sams Teach Yourself Flashâ„¢ MX ActionScript in 24 Hours
Entries (RSS)