EasyManua.ls Logo

MACROMEDIA FLASH MX 2004 - ACTIONSCRIPT - Loading JPEG Files into Movie Clips

MACROMEDIA FLASH MX 2004 - ACTIONSCRIPT
816 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
124 Chapter 7: Working with Movie Clips
When contents.swf loads into the movie clip in container.swf, the value of userName that’s
attached to the root Timeline of the hosting SWF file (container.swf ) would be set to
"Mary".
This could cause code in container.swf (as well as contents.swf) to malfunction.
To f o rc e
_root to always evaluate to the Timeline of the loaded SWF file, rather than the actual
root Timeline, use the
_lockroot property. This property can be set either by the loading SWF
file or the SWF file being loaded. When
_lockroot is set to true on a movie clip instance, that
movie clip will act as
_root for any SWF file loaded into it. When _lockroot is set to true
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
_lockroot to true. By default, this
property is
false.
For example, the author of container.swf could attach the following code to the
target_mc movie
clip:
// Attached to target_mc movie clip:
onClipEvent (load) {
this._lockroot = true;
}
This would ensure that references to _root in contents.swf—or any SWF file loaded into
target_mc—will refer to its own Timeline, not the actual root Timeline of container.swf.
Equivalently, the author of contents.swf could add the following code to its main Timeline.
// Within contents.swf:
this._lockroot = true;
This would ensure that no matter where contents.swf is loaded, any reference it makes to _root
will refer to its own main Timeline, not that of the hosting SWF file.
For more information, see
MovieClip._lockroot on page 515.
Loading JPEG files into movie clips
You can use the loadMovie() function, or the MovieClip method of the same name, to load
JPEG image files into a movie clip instance. You can also use the
loadMovieNum() function to
load a JPEG file into a level.
When you load an image into a movie clip, the upper left corner of the image is placed at the
registration point of the movie clip. Because this registration point is often the center of the movie
clip, the loaded image may not appear centered. Also, when you load an image to a root Timeline,
the upper left corner of the image is placed on the upper left corner of the Stage. The loaded
image inherits rotation and scaling from the movie clip, but the original content of the movie clip
is removed.
For more information, see “Loading external SWF and JPEG files” on page 194,
loadMovie()
on page 420,
MovieClip.loadMovie() on page 512, and loadMovieNum() on page 421.

Table of Contents

Related product manuals