startDrag( ) Global Function

ActionScript for Flash MX: The Definitive Guide, 2nd Edition
By Colin Moock
Chapter 18.  ActionScript Language Reference
startDrag( ) Global Function Flash 4

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

Arguments

target

A string or reference indicating the path to the movie or movie clip instance that should follow the mouse pointer (references to movie clips are converted to paths when used in a string context).

lockCenter

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

left

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

top

A number specifying the minimum y-coordinate above which target's registration point cannot be dragged.

right

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

bottom

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

Description

The startDrag( ) function causes target to follow the mouse pointer around in the Player visually (known as dragging the clip). The movement of a dragged clip can be constrained to a bounding box whose coordinates are provided as arguments to the startDrag( ) function. Bounding box coordinates are given relative to the canvas on which target resides. If that canvas is the main movie Stage, then (0,0) is the top-left corner of the Stage. If that canvas is a movie clip, then (0,0) is the registration point of the clip's canvas. Note that Flash's coordinate system reverses the Cartesian Y-axis; y values increase toward the bottom of the screen and decrease toward the top of the screen. Negative y values are above the origin (i.e., above the X-axis).

Dragging can be stopped at any time via the stopDrag( ) function. Only one movie clip or movie can be dragged at a time, so issuing a startDrag( ) function on a new target automatically cancels any drag operation already in progress. That said, when a movie or movie clip is dragged, all the movie clips it contains are dragged along with it.

Example

// Drag ball, limiting its movement to the upper-left corner of the Stage startDrag("ball", true, 0, 0, 225, 200);

See Also

MovieClip._dropTarget, MovieClip.startDrag( ), stopDrag( )



    ActionScript for Flash MX. The Definitive Guide
    ActionScript for Flash MX: The Definitive Guide, Second Edition
    ISBN: 059600396X
    EAN: 2147483647
    Year: 2002
    Pages: 780
    Authors: Colin Moock

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net