Changing movie clip position and appearance 357
This step ensures that any references to _root in contents.swf—or any SWF file loaded into
target_mc—refers to its own timeline, not to the actual root timeline of container.swf. Now
when you click the button, "
Tim" appears.
Alternatively, the author of contents.swf could add the following code to its main timeline:
// Added to Frame 1 in contents.swf:
this._lockroot = true;
This would ensure that no matter where contents.swf is loaded, any reference it makes to
_root refers to its own main timeline, not to that of the hosting SWF file.
For more information, see _lockroot (MovieClip._lockroot property).
Loading image files into movie clips
You can use the loadMovie() function, or the MovieClip method of the same name, to load
image files into a movie clip instance. You can also use the
loadMovieNum() function to load
an image 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 might 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
loadMovie function, loadMovie
(
MovieClip.loadMovie method), and loadMovieNum function in the ActionScript
2.0 Language Reference and “Loading external SWF and image files” on page 593.
Changing movie clip position and
appearance
To change the properties of a movie clip as it plays, write a statement that assigns a value to a
property or use the
setProperty() function. For example, the following code sets the
rotation of instance
mc to 45:
my_mc._rotation = 45;
This is equivalent to the following code, which uses the setProperty() function:
setProperty("my_mc", _rotation, 45);