Working with Movie Clips and Buttons > Using actions and methods to control movie clips > Changing movie clip position and appearance |
![]() ![]() ![]() |
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
action. For example, the following code sets the rotation of instance mc
to 45:
mc._rotation = 45;
This is equivalent to the following code, which uses the setProperty
action:
setProperty("mc", _rotation, 45);
Some properties, called read-only properties, have values that you can read but not set. (These properties are specified as read-only in their ActionScript Dictionary 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;
In addition, you can write statements that get the value of a movie clip property. For example, the following statement gets the value of the _xmouse
property on the current level's Timeline and sets the _x
property of the customCursor
instance to that value:
onClipEvent(enterFrame){ customCursor._x = _root._xmouse; }
This is equivalent to the following code, which uses the getProperty
function:
onClipEvent(enterFrame){ customCursor._x = getProperty(_root, _xmouse); }
The _x
, _y
, _rotation
, _xscale
, _yscale
, _height
, _width
, _alpha
, and _visible
properties are affected by transformations on the movie clip's parent, and transform the movie clip and any of the clip's children. The _focusrect
, _highquality
, _quality
, and _soundbuftime
properties are global; they belong only to the level 0 main Timeline. All other properties belong to each movie clip or loaded level.
For a list of movie clip properties, see MovieClip (object) in the ActionScript Dictionary.
![]() ![]() ![]() |