![MACROMEDIA FLASH MX 2004 - ACTIONSCRIPT Reference Manual Download Page 123](http://html1.mh-extra.com/html/macromedia/flash-mx-2004-actionscript/flash-mx-2004-actionscript_reference-manual_3378897123.webp)
Specifying a root Timeline for loaded SWF files
123
The above code is also equivalent to the following:
with (donut){
hole._alpha = 20;
hole._xscale = 150;
hole._yscale = 150;
}
Loading and unloading additional SWF files
To play additional SWF files without closing Flash Player, or to switch SWF files without loading
another HTML page, you can use the global
loadMovie()
function or
loadMovie()
method of
the MovieClip class. You can also use
loadMovie()
to send variables to a CGI script, which
generates a SWF file as its CGI output. When you load a SWF file, you can specify a level or
movie clip target into which the SWF file will load. If you load a SWF file into a target, the
loaded SWF file inherits the properties of the targeted movie clip. Once the movie is loaded, you
can change those properties.
The
unloadMovie()
method removes a SWF file previously loaded by
loadMovie()
. Explicitly
unloading SWF files with
unloadMovie()
ensures a smooth transition between SWF files and
may decrease the memory required by Flash Player.
Use
loadMovie()
to do any of the following:
•
Play a sequence of banner ads that are SWF files by placing a
loadMovie()
function at the end
of each SWF file to load the next SWF file.
•
Develop a branching interface that lets the user choose among several different SWF files.
•
Build a navigation interface with navigation controls in level 0 that load other levels. Loading
levels produces smoother transitions than loading new HTML pages in a browser.
For more information on loading movies, see
“Loading external SWF and JPEG files”
on page 194
.
Specifying a root Timeline for loaded SWF files
The
_root
ActionScript property specifies or returns a reference to the root Timeline of a SWF
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
_root
,
_level1
is returned.
However, the Timeline specified by
_root
can change depending on whether a SWF file is
running independently (in its own level) or has been loaded into a movie clip instance by a
loadMovie()
call.
For example, consider a file named container.swf that has a movie clip instance named
target_mc
on its main Timeline. The container.swf file declares a variable named
userName
on its main
Timeline; the same script then loads another file called contents.swf into the movie clip
target_mc
.
// In container.swf:
_root.userName = "Tim";
target_mc.loadMovie("contents.swf");
The loaded SWF file, contents.swf, also declares a variable named
userName
on its root Timeline.
// In content.swf:
_root.userName = "Mary";
Summary of Contents for FLASH MX 2004 - ACTIONSCRIPT
Page 1: ...ActionScript Reference Guide...
Page 8: ...8 Contents...
Page 12: ......
Page 24: ...24 Chapter 1 What s New in Flash MX 2004 ActionScript...
Page 54: ...54 Chapter 2 ActionScript Basics...
Page 80: ...80 Chapter 3 Writing and Debugging Scripts...
Page 82: ......
Page 110: ...110 Chapter 5 Creating Interaction with ActionScript...
Page 112: ......
Page 120: ...120 Chapter 6 Using the Built In Classes...
Page 176: ......
Page 192: ...192 Chapter 10 Working with External Data...
Page 202: ...202 Chapter 11 Working with External Media...
Page 204: ......
Page 782: ...782 Chapter 12 ActionScript Dictionary...
Page 793: ...Other keys 793 221 222 Key Key code...
Page 794: ...794 Appendix C Keyboard Keys and Key Code Values...
Page 798: ...798 Appendix D Writing Scripts for Earlier Versions of Flash Player...
Page 806: ...806 Appendix E Object Oriented Programming with ActionScript 1...
Page 816: ...816 Index...