stopDrag( ) Global Function

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

end a drag operation in progress
stopDrag()

Description

The startDrag( ) function causes a movie clip to follow the mouse pointer around the Stage. A stopDrag( ) operation stops a dragged movie clip from following the mouse pointer. Because only one movie clip or movie can be dragged at a time, stopDrag( ) does not require a target argument; it simply cancels any drag operation in progress.

Together with startDrag( ), stopDrag( ) is used to create simple drag-and-drop interfaces in Flash, as demonstrated under "Interface Widgets" in the online Code Depot. If a dragged clip is dropped on top of another clip, the clip on which it was dropped is available through the MovieClip._droptarget property.

Example

The following code causes window_mc to be dragged while the mouse is pressed over it and dropped when the mouse is released. Note that we stop dragging the clip when either onRelease( ) or onReleaseOutside( ) is detected, ensuring that the clip is dropped, regardless of whether the mouse is actually over the clip when it is released:

window_mc.onPress = function () {   this.startDrag(); }     window_mc.onRelease = window_mc.onReleaseOutside = function () {   stopDrag(); }

See Also

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

     
       About Safari   |   Terms of Service   |   Privacy Policy   |   Contact Us   |   Help   |   Submit a Problem
    Copyright 2002 O'Reilly & Associates, Inc. All rights reserved.
    1005 Gravenstein Highway North
    Sebastopol, CA 95472
     


    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