Controlling Nested Timeline from Main Timeline
Flash CS4 ActionScript 3.0 Tutorial
How to Control a Nested Timeline with Code on the Main Flash Timeline
Nesting symbols is a common technique when working with Button Symbols and Movie Symbols. It allows you to create a parent/child relationship for simplified moving. You can also use ActionScript to talk to a nested movie at any level of the hierarchy.
In this example we will nest one Movie Symbol within another Movie Symbol. ActionScript is then added to the main timeline to control the nested Movie Symbol.
Movie Symbol named holder_mc
Movie Symbol named nested_mc
Open a new Flash document and add one additional layer.
Name the top layer Actions and the lower layer Content.
Choose Insert > New Symbol (Cmd/F8 (PC - Ctrl/F8).
Select Movie Clip for type and name your new symbol Holder.
Use the Rectangle tool to add a red rectangle inside the Holder Movie Symbol at the center of the stage.
Select the rectangle and press F8 to convert it to a Movie Symbol. Name the symbol RedBox.
Click the rectangle and assign it an instance name of nested_mc.
Double-Click the RedBox symbol to enter the editing mode.
Add a new layer inside RedBox and name it Actions.
Add keyframes for both layers at frame five by clicking frame five and pressing F6.
Add the following code to the Actions layer keyframes one and five.
Change the color of the rectangle to blue at frame five.
Return to the main stage by clicking the scene icon.
Drag the Holder symbol from the Library to the center of the stage on the Content layer.
Select the instance of the Holder symbol and assign it an instance name of holder_mc in the Properties panel.
Option double-click (PC - Alt double-click) frame one of the Actions layer.
Copy/Paste the following code to the ActionScript panel.
Click frame twenty of the Content layer and press F5 to extend the content for twenty frames.
Publish your movie by pressing Cmd/Return (PC - Ctrl/Enter). The movie on the main stage plays. When the main timeline hits frame 20, it loops back to frame one. Each time the timeline hits frame one, the external movie is told to play, which changes the color.