User Guide

210 Chapter 8: Working with Movie Clips
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 my_mc instance to that value:
this.onEnterFrame = function() {
my_mc._x = this._xmouse;
};
This is equivalent to the following code, which uses the getProperty() function:
this.onEnterFrame = function() {
my_mc._x = getProperty(_root, _xmouse);
};
The _x, _y, _rotation, _xscale, _yscale, _height, _width, _alpha, and _visible properties
are affected by transformations on the movie clips parent, and transform the movie clip and any
of the clips 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 “Property summary for the MovieClip class” in Flash
ActionScript Language Reference.
Dragging movie clips
You can use the global startDrag() function or the MovieClip.startDrag() method to make
a movie clip draggable. For example, you can make a draggable movie clip for games, drag-and-
drop functions, customizable interfaces, scroll bars, and sliders.
A movie clip remains draggable until explicitly stopped by
stopDrag() or until another movie
clip is targeted with
startDrag(). Only one movie clip at a time can be dragged in a SWF file.
To create more complicated drag-and-drop behavior, you can evaluate the
_droptarget property
of the movie clip being dragged. For example, you might examine the
_droptarget property to
see if the movie clip was dragged onto a specific movie clip (such as a “trash can” movie clip) and
then trigger another action, as shown in the following example:
//Drag a piece of garbage
garbage_mc.onPress = function() {
this.startDrag(false);
};
//When the garbage is dragged over the trashcan, make it invisible
garbage_mc.onRelease = function() {
this.stopDrag();
//convert the slash notation to dot notation using eval
if (eval(this._droptarget) == trashcan_mc) {
garbage_mc._visible = false;
}
};
For more information, see startDrag() or MovieClip.startDrag() in Flash ActionScript
Language Reference.