Control Nested Movie A with Button in Nested Movie B
Flash CS4 ActionScript 3.0 Tutorial
How to Control a Nested Movie Timeline with a Button in Another Flash Nested Movie
Nested Movie Symbol timeline control can come from a button on the main stage or a button in another nested movie. In this example we have a button located inside a nested movie that controls the playhead of a second nested movie on main timeline. A Nested Symbol is one that is placed inside another Button Symbol or Movie Symbol.
Movie Symbol with instance name buttonHolder_mc
Movie Symbol with instance name twoFrame_mc
Button Symbol with instance name nestedButton_btn (located inside buttonHolder_mc)
Open a new Flash document and name the default layer Content.
Add a new top layer and name it Actions.
Choose Insert > New Symbol (Cmd/F8 (PC - Ctrl/F8).
Name your symbol ButtonHolder, choose Movie Clip for type, then press OK.
You are now inside the new Movie Symbol. Draw a rectangle on the stage. This will be your new button.
Click the rectangle and press F8 to convert it to a Button Symbol. Name your button NestedButton and press OK.
Double-click the button to edit the button. Press F6 three times to copy/paste the Up content to the Over, Down and Hit keyframes.
Click the ButtonHolder icon to return to the ButtonHolder edit screen.
Click the button and give it an instance name of nestedButton_btn in the Properties panel.
Click the Scene icon to return to the main timeline.
Click frame one of the Content layer and drag the ButtonHolder from the Library to the stage.
Click the new button and give it an instance name of buttonHolder_mc in the Properties panel.
Add an oval to the stage on the Content layer and press F8 to convert it to a Movie Symbol.
Double-click the oval. Now your are in the symbol edit mode. Press F6 to duplicate frame one
Change the color of the oval in frame two, the press the Scene icon to return to the main stage.
Click the oval Movie Symbol and assign it an instance name of twoFrame_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.
Test your movie by pressing Cmd/Return (PC - Ctrl/Enter). Click the nested button. The nested oval shape's timeline should go to frame two and stop.
Dissecting the Code
The first line stops the twoFrame_mc timeline at frame one. The next line adds an event listener to the nestedButton_btn that is inside the btnHolder_mc. Once it hears a mouse click, the function frameChange is run.
The line, twoFrame_mc.gotoAndStop(2), tells the twoFrame_mc timeline to go to frame 2 and stop.