Packageorg.aswing.dnd
Classpublic class DragManager

Drag and Drop Manager.

Thanks Bill Lee for the original DnD implementation for AsWing AS2 version.



Public Properties
 PropertyDefined by
  DEFAULT_DROP_MOTION : DropMotion
[static]
DragManager
  DEFAULT_REJECT_DROP_MOTION : DropMotion
[static]
DragManager
  TYPE_COPY : Number = 2
[static]
DragManager
  TYPE_MOVE : Number = 1
[static]
DragManager
  TYPE_NONE : Number = 0
[static]
DragManager
Public Methods
 MethodDefined by
  
[static] Adds a drag listener to listener list.
DragManager
  
[static] Returns the drag image.
DragManager
  
getCurrentDropTarget():DisplayObject
[static] Returns current drop target of dragging components by startDrag method.
DragManager
  
[static] Returns current drop target component of dragging components by startDrag method.
DragManager
  
[static] Returns current drop target drop trigger component of dragging components by startDrag method.
DragManager
  
getDropTarget(stage:Stage, pos:Point = null, targetType:Class = null, addtionCheck:Function = null):DisplayObject
[static] Returns the drop target of specified position and specified class type.
DragManager
  
getDropTargetComponent(pos:Point = null):Component
[static] Returns current drop target component of specified position.
DragManager
  
[static] Returns drop target drop trigger component of specified global position.
DragManager
  
[static] Removes the specified listener from listener list.
DragManager
  
setDragingImageContainerRoot(theRoot:DisplayObjectContainer):void
[static] Sets the container to hold the draging image(in fact it will hold the image's parent--a sprite).
DragManager
  
[static] Sets the motion of drag movie clip when a drop acted.
DragManager
  
startDrag(dragInitiator:Component, sourceData:SourceData, dragImage:DraggingImage = null, dragListener:DragListener = null):void
[static] startDrag(dragInitiator:Component, dragSource, dragImage:MovieClip, lis:DragListener)
startDrag(dragInitiator:Component, dragSource, dragImage:MovieClip)
startDrag(dragInitiator:Component, dragSource)

Starts dragging a initiator, with dragSource, a dragging Image, and a listener.

DragManager
Property detail
DEFAULT_DROP_MOTIONproperty
public static var DEFAULT_DROP_MOTION:DropMotion
DEFAULT_REJECT_DROP_MOTIONproperty 
public static var DEFAULT_REJECT_DROP_MOTION:DropMotion
TYPE_COPYproperty 
public static var TYPE_COPY:Number = 2
TYPE_MOVEproperty 
public static var TYPE_MOVE:Number = 1
TYPE_NONEproperty 
public static var TYPE_NONE:Number = 0
Method detail
addDragListener()method
public static function addDragListener(lis:DragListener):void

Adds a drag listener to listener list.

Parameters
lis:DragListener — the listener to be add
getCurrentDragImage()method 
public static function getCurrentDragImage():DraggingImage

Returns the drag image.

Returns
DraggingImage
getCurrentDropTarget()method 
public static function getCurrentDropTarget():DisplayObject

Returns current drop target of dragging components by startDrag method.

Returns
DisplayObject — the drop target

See also

getCurrentDropTargetComponent()method 
public static function getCurrentDropTargetComponent():Component

Returns current drop target component of dragging components by startDrag method.

Returns
Component — the drop target component

See also

getCurrentDropTargetDropTriggerComponent()method 
public static function getCurrentDropTargetDropTriggerComponent():Component

Returns current drop target drop trigger component of dragging components by startDrag method.

Returns
Component — the drop target drop trigger component

See also

getDropTarget()method 
public static function getDropTarget(stage:Stage, pos:Point = null, targetType:Class = null, addtionCheck:Function = null):DisplayObject

Returns the drop target of specified position and specified class type. For example:

  getDropTarget(new Point(0, 0), TextField);
  will return the first textfield insance under the point, or null if not found.
  
  getDropTarget(null, null);
  will return the first display object insance under the current mouse point, or null if not found.
  

Parameters
stage:Stage — the stage where the drop target should be in
 
pos:Point (default = null) — The point under which to look, in the coordinate space of the Stage.
 
targetType:Class (default = null) — the class type of the target, default is null, means any display object.
 
addtionCheck:Function (default = null) — a check function, only return the target when function(target:DisplayOject) return true. default is null, means no this check.

Returns
DisplayObject — drop target
getDropTargetComponent()method 
public static function getDropTargetComponent(pos:Point = null):Component

Returns current drop target component of specified position.

Parameters
pos:Point (default = null) — the global point

Returns
Component — the drop target component

See also

getDropTragetDropTriggerComponent()method 
public static function getDropTragetDropTriggerComponent(pos:Point = null):Component

Returns drop target drop trigger component of specified global position.

Parameters
pos:Point (default = null) — the point

Returns
Component — the drop target drop trigger component

See also

removeDragListener()method 
public static function removeDragListener(lis:DragListener):void

Removes the specified listener from listener list.

Parameters
lis:DragListener — the listener to be removed
setDragingImageContainerRoot()method 
public static function setDragingImageContainerRoot(theRoot:DisplayObjectContainer):void

Sets the container to hold the draging image(in fact it will hold the image's parent--a sprite). By default(if you have not set one), it will be the AsWingManager.getRoot() value.

Parameters
theRoot:DisplayObjectContainer — the container to hold the draging image.

See also

setDropMotion()method 
public static function setDropMotion(motion:DropMotion):void

Sets the motion of drag movie clip when a drop acted.

Generally if you want to do a custom motion of the dragging movie clip when dropped, you may call this method in the listener's onDragDrop() method.

Every drop acted, the default motion will be set to DirectlyRemoveMotion so you need to set to yours every drop time if you want. Parameters

motion:DropMotion — the motion

See also

startDrag()method 
public static function startDrag(dragInitiator:Component, sourceData:SourceData, dragImage:DraggingImage = null, dragListener:DragListener = null):void

startDrag(dragInitiator:Component, dragSource, dragImage:MovieClip, lis:DragListener)
startDrag(dragInitiator:Component, dragSource, dragImage:MovieClip)
startDrag(dragInitiator:Component, dragSource)

Starts dragging a initiator, with dragSource, a dragging Image, and a listener. The drag action will be finished at next Mouse UP/Down Event(Mouse UP or Mouse Down, generally you start a drag when mouse down, then it will be finished when mouse up, if you start a drag when mouse up, it will be finished when mouse down). Parameters

dragInitiator:Component — the dragging initiator
 
sourceData:SourceData — the data source will pass to the listeners and target components
 
dragImage:DraggingImage (default = null) — (optional)the image to drag, default is a rectangle image.
 
dragListener:DragListener (default = null) — (optional)the listener added to just for this time dragging action, default is null(no listener)