Table of Contents

MovieClip.startDrag( ) Method Flash 5

make a movie or movie clip follow the mouse
mc.startDrag()
mc.startDrag(lockCenter)
mc.startDrag(lockCenter, left, top, right, bottom )

Arguments

lockCenter

A Boolean indicating whether the registration point of mc should be centered under the mouse pointer (true) or dragged relative to its original location (false).

left

A number specifying the x-coordinate to the left of which mc's registration point cannot be dragged.

top

A number specifying the y-coordinate above which mc's registration point may not be dragged.

right

A number specifying the x-coordinate to the right of which mc's registration point cannot be dragged.

bottom

A number specifying the y-coordinate below which mc's registration point cannot be dragged.

Description

The MovieClip.startDrag( ) method is an alternative to the global startDrag( ) function. When invoked as a MovieClip method, startDrag( ) does not take a target parameter; it drags mc. The MovieClip method syntax is less prone to user error than its global function counterpart because no target parameter is required.

For usage instructions, see the global startDrag( ) function.

Bugs

Note that the correct order of the constraining rectangular coordinates is left, top, right, bottom, but the Flash 5 ActionScript Dictionary lists them in the wrong order under MovieClip.startDrag( ).

Example

// Code to drag and drop the current clip or movie
this.onPress = function () {
  this.startDrag(true);
};
   
this.onRelease = function () {
  stopDrag();
}

See Also

MovieClip.stopDrag( ), startDrag( ), stopDrag( ); Section 13.7


Table of Contents