Table of Contents

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( )


Table of Contents