Specifying A Root Timeline For Loaded Swf Files - MACROMEDIA FLASH MX 2004-USING ACTIONSCRIPT IN FLASH Use Manual

Using actionscript in flash
Hide thumbs Also See for FLASH MX 2004-USING ACTIONSCRIPT IN FLASH:
Table of Contents

Advertisement

Develop a branching interface with links that lets the user select among several SWF files that
are used to display a site's content.
Build a navigation interface with navigation controls in level 0 that loads content into other
levels. Loading content into levels helps produce smoother transitions between pages of
content than loading new HTML pages in a browser.
For more information on loading movies, see
on page
296.

Specifying a root Timeline for loaded SWF files

The
ActionScript property specifies or contains a reference to the root Timeline of a SWF
_root
file. If a SWF file has multiple levels, the root Timeline is on the level that contains the currently
executing script. For example, if a script in level 1 evaluates
However, the Timeline specified by
running independently (in its own level) or has been loaded into a movie clip instance by a
call.
loadMovie()
In the following example, consider a file named container.swf that has a movie clip instance
named
target_mc
on its main Timeline; the same script then loads another file called contents.swf into
userName
the movie clip
target_mc
// In container.swf:
_root.userName = "Tim";
target_mc.loadMovie("contents.swf");
myButton.onRelease = function() {
trace(_root.userName);
};
In the following example, the loaded SWF file, contents.swf, also declares a variable named
on its root Timeline:
userName
// In contents.swf:
_root.userName = "Mary";
After contents.swf loads into the movie clip in container.swf, the value of
attached to the root Timeline of the hosting SWF file (container.swf ) would be set to
instead of
"Tim"
To force
to always evaluate to the Timeline of the loaded SWF file, rather than the actual
_root
root Timeline, use the
file or the SWF file being loaded. When
movie clip will act as
within a SWF file, that SWF file will act as its own root, no matter what other SWF file loads it.
Any movie clip, and any number of movie clips, can set
property is
false
For example, the author of container.swf could put the following code on Frame 1 of the main
Timeline:
// Added to Frame 1 in container.swf:
target_mc._lockroot = true;
208
Chapter 8: Working with Movie Clips
_root
on its main Timeline. The container.swf file declares a variable named
.
. This could cause code in container.swf (as well as contents.swf ) to malfunction.
property. This property can be set either by the loading SWF
_lockroot
for any SWF file loaded into it. When
_root
.
"Loading external SWF and JPEG files"
_root
can change, depending on whether a SWF file is
is set to
_lockroot
true
_lockroot
,
is returned.
_level1
that's
userName
"Mary"
on a movie clip instance, that
is set to
_lockroot
true
to
. By default, this
true

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flash mx 2004 - actionscript

Table of Contents