13.08.2012 Views

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>ACTIONSCRIPT</strong> 3.0 DEVELOPER’S GUIDE<br />

Drag and drop in AIR<br />

Package Classes<br />

flash.desktop NativeDragManager<br />

NativeDragOptions<br />

Clipboard<br />

URLFilePromise<br />

IFilePromise<br />

Constants used with the drag-and-drop API are defined in the following classes:<br />

NativeDragActions<br />

ClipboardFormat<br />

ClipboardTransferModes<br />

flash.ev<strong>en</strong>ts NativeDragEv<strong>en</strong>t<br />

Drag-and-drop gesture stages<br />

The drag-and-drop gesture has three stages:<br />

Initiation A user initiates a drag-and-drop operation by dragging from a compon<strong>en</strong>t, or an item in a compon<strong>en</strong>t, while<br />

holding down the mouse button. The compon<strong>en</strong>t that is the source of the dragged item is typically designated as the<br />

drag initiator and dispatches nativeDragStart and nativeDragComplete ev<strong>en</strong>ts. An Adobe AIR application starts<br />

a drag operation by calling the NativeDragManager.doDrag() method in response to a mouseDown or mouseMove<br />

ev<strong>en</strong>t.<br />

If the drag operation is initiated from outside an AIR application, there is no initiator object to dispatch<br />

nativeDragStart or nativeDragComplete ev<strong>en</strong>ts.<br />

Dragging While holding down the mouse button, the user moves the mouse cursor to another compon<strong>en</strong>t, application,<br />

or to the desktop. As long as the drag is underway, the initiator object dispatches nativeDragUpdate ev<strong>en</strong>ts. (However,<br />

this ev<strong>en</strong>t is not dispatched in AIR for Linux.) Wh<strong>en</strong> the user moves the mouse over a possible drop target in an AIR<br />

application, the drop target dispatches a nativeDragEnter ev<strong>en</strong>t. The ev<strong>en</strong>t handler can inspect the ev<strong>en</strong>t object to<br />

determine whether the dragged data is available in a format that the target accepts and, if so, let the user drop the data<br />

onto it by calling the NativeDragManager.acceptDragDrop() method.<br />

As long as the drag gesture remains over an interactive object, that object dispatches nativeDragOver ev<strong>en</strong>ts. Wh<strong>en</strong><br />

the drag gesture leaves the interactive object, it dispatches a nativeDragExit ev<strong>en</strong>t.<br />

Drop The user releases the mouse over an eligible drop target. If the target is an AIR application or compon<strong>en</strong>t, th<strong>en</strong> the<br />

target object dispatches a nativeDragDrop ev<strong>en</strong>t. The ev<strong>en</strong>t handler can access the transferred data from the ev<strong>en</strong>t<br />

object. If the target is outside AIR, the operating system or another application handles the drop. In both cases, the<br />

initiating object dispatches a nativeDragComplete ev<strong>en</strong>t (if the drag started from within AIR).<br />

The NativeDragManager class controls both drag-in and drag-out gestures. All the members of the<br />

NativeDragManager class are static, do not create an instance of this class.<br />

The Clipboard object<br />

Data that is dragged into or out of an application or compon<strong>en</strong>t is contained in a Clipboard object. A single Clipboard<br />

object can make available differ<strong>en</strong>t repres<strong>en</strong>tations of the same information to increase the likelihood that another<br />

application can understand and use the data. For example, an image could be included as image data, a serialized<br />

Bitmap object, and as a file. R<strong>en</strong>dering of the data in a format can be deferred to a r<strong>en</strong>dering function that is not called<br />

until the data is read.<br />

Last updated 6/6/2012<br />

608

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!