User Guide
Changing movie clip position and appearance 209
This step ensures that any 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. Now
when you click the button, "
Tim" appears.
Equivalently, 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
will refer to its own main Timeline, not that of the hosting SWF file.
For more information, see
MovieClip._lockroot.
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 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(), MovieClip.loadMovie(), and loadMovieNum() in
Flash ActionScript Language Reference and “Loading external SWF and JPEG files” on page 296.
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:
this.my_mc._rotation = 45;
This is equivalent to the following code, which uses the setProperty() function:
setProperty("mc", _rotation, 45);
Some properties, called read-only properties, have values that you can read but cannot set. (These
properties are specified as read-only in their ActionScript Language Reference entries.) The
following are read-only properties:
_currentframe, _droptarget, _framesloaded, _parent,
_target, _totalframes, _url, _xmouse, and _ymouse.
You can write statements to set any property that is not read-only. The following statement sets
the
_alpha property of the movie clip instance wheel, which is a child of the car instance:
car.wheel._alpha = 50;