Name

MovieClip.startDrag( ) Method — make a movie or movie clip follow the mouse

Availability

Method form introduced in Flash 5 (global form supported by Flash 4 and later)

Synopsis

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 may not 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 may not be dragged.

bottom

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

Description

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

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 that the Flash 5 ActionScript Dictionary lists them in the wrong order under MovieClip.startDrag( ).

Example

// Button code to drag and drop the current clip or movie on (press) { this.startDrag(true); } on ...

Get ActionScript: The Definitive Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.