
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
346
|
Chapter 13: Movie Clips
• When manually created instances are initially loaded, code in their timeline and
onLoad() event handlers executes according to the Load Order set in the Publish
Settings of a Flash document—either Bottom Up, which is the default, or Top
Down.
For example, suppose we have a timeline with two layers, top and bottom, where
top is above bottom in the layer stack. We place clip
X on layer top and clip Y on
layer bottom. If the Load Order of the document is set to Bottom Up, then the
code in clip
Y will execute before the code in clip X. If, on the other hand, the
Load Order of the document is set to Top Down, then the code in clip
X will exe-
cute before the code in clip
Y. This execution order applies only to the frame on
which X and Y appear for the first time.
• Once loaded, all instances of a movie are added to an execution order, which is
the reverse of the load order; the last instance added to the movie is always the
first to have its code executed.
Use caution when relying on these rules. Layers are mutable, so you should avoid
producing code that relies on their relative position. Strive to create code that exe-
cutes safely without relying on the execution order of the clips in the stack. We can
avoid some of the issues presented by the execution stack