Macromedia ActionScript Tutorial
Independent Timelines
Properties
Movie
Observations
Construction
Movie Explorer
Notes
Comments on movie design
Name: Independent Timelines
ID = 2 Version: A SWF file size = 8 KB Posted: 2/26/02
Level: Intermediate
Primary Focus: Timelines, onClipEvent(enterFrame)
Secondary Focus: toggle button, play(); stop(); dynamic text boxes
Approach: Dynamic text boxes monitor position of playhead in
both the main movie and a movie clip.
Use the toggle buttons to start and stop the playhead of the main movie or the playhead of the movie clip.
1. In this movie example the loop number increases faster for the movie clip than for the main movie.
2. The main movie and the movie clip can be stopped or started independent of the state of the other.
3. The rate at which numbers appear in the main movie is the same as that for the movie clip.
4. Nothing stops the onClipEvent(enterFrame) handler.
5. Stopping the main movie playhead does not stop (deactivate) the main movie. The main movie must still be active because it detects the button release to start the playhead moving again.
1. Modify > Movie was used to set the frame rate of the movie to 2 frames/sec.
2. In the main movie two dynamic text boxes were added that monitor the frame location of the playhead and the number of times the playhead loops through the 10 frame main movie timeline. A toggle button was dragged from the library onto the stage. The dynamic text boxes and the toggle button appear in each of the ten frames of the main movie. ActionScript statements attached to these frames increment the values of the two dynamic text box variables each time the playhead enters a frame.
3. Insert > New Symbol was used to create a movie clip (MC1) containing three dynamic text boxes and a toggle button in each of its five frames. The dynamic text boxes monitor the frame location of the playhead and the number of times the playhead loops through the 5 frame movie clip timeline.
4. The movie clip (MC1) was dragged from the movie library to the main stage to create the movie clip instance MC1IN. It appears in all ten frames of the main movie. An onClipEvent(enterFrame) handler was attached to the movie clip instance. ActionScript statements within the handler increase a dynamic text box variable by one each time the handler is repeated.
5. Before publishing this movie the File>Publish Settings >HTML >Playback was set to loop.
1. This play() function applies to the main movie since it is inside a button handler that is
attached to the main movie. The ActionScript statements in this button handler toggle between
the play() and stop() function.2. In the main movie the movie clip instance MC1IN was selected and then the onClipEvent(enterFrame) handler was attached to it.
3. The first frame of the main movie was selected and these ActionScript statements attached to it.
4. Each frame of the 10 frame main movie had an ActionScript statement attached to it that inserted the frame number into the dynamic text box variable that displays the main movie frame number.
5. The first frame of the movie clip symbol MC1 was selected and these ActionScript statements
attached to it.6. Each frame of the 5 frame movie clip symbol had an ActionScript statement attached to it that inserted the frame number into the dynamic text box variable that displays the movie clip frame number.
7. Here the play() function is within the button handler for the button that was attached to the movie clip so it controls the movie clip playhead not the main movie playhead.
8. MC1LoopNumber is the dynamic text box variable that was created on the movie clip symbol stage.
This tutorial was designed to demonstrate the independence of a movie clip timeline from that of the main movie timeline. Hopefully it also points out that the stop() function does not stop the movie it only stops the movement of the playhead.
Notice that the ActionScript is scattered around in this movie. It is attached to frames, buttons, and movie clips. For the purposes of this tutorial, covering a relatively simple movie, this is probably OK but in general for more complicated movies the code should be consolidated, whenever possible, in one location by the use of functions. This will be discussed in later tutorials.
2002-7 All rights reserved. MINDdrops.com