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 />

Property or Method Description<br />

effectAllowed The effect allowed by the source of the drag. Typically, the handler for the dragstart ev<strong>en</strong>t sets this value. See<br />

“Drag effects in HTML” on page 617.<br />

dropEffect The effect chos<strong>en</strong> by the target or the user. If you set the dropEffect in a dragover or drag<strong>en</strong>ter ev<strong>en</strong>t<br />

handler, th<strong>en</strong> AIR updates the mouse cursor to indicate the effect that occurs if the user releases the mouse. If<br />

the dropEffect set does not match one of the allowed effects, no drop is allowed and the unavailable cursor<br />

is displayed. If you have not set a dropEffect in response to the latest dragover or drag<strong>en</strong>ter ev<strong>en</strong>t, th<strong>en</strong><br />

the user can choose from the allowed effects with the standard operating system modifier keys.<br />

MIME types for the HTML drag-and-drop<br />

Adobe AIR 1.0 and later<br />

The final effect is reported by the dropEffect property of the object dispatched for drag<strong>en</strong>d. If the user<br />

abandons the drop by releasing the mouse outside an eligible target, th<strong>en</strong> dropEffect is set to none.<br />

types An array containing the MIME type strings for each data format pres<strong>en</strong>t in the dataTransfer object.<br />

getData(mimeType) Gets the data in the format specified by the mimeType parameter.<br />

The getData() method can only be called in response to the drop ev<strong>en</strong>t.<br />

setData(mimeType) Adds data to the dataTransfer in the format specified by the mimeType parameter. You can add data in<br />

multiple formats by calling setData() for each MIME type. Any data placed in the dataTransfer object by<br />

the default drag behavior is cleared.<br />

The setData() method can only be called in response to the dragstart ev<strong>en</strong>t.<br />

clearData(mimeType) Clears any data in the format specified by the mimeType parameter.<br />

setDragImage(image,<br />

offsetX, offsetY)<br />

The MIME types to use with the dataTransfer object of an HTML drag-and-drop ev<strong>en</strong>t include:<br />

Data format MIME type<br />

Text "text/plain"<br />

HTML "text/html"<br />

URL "text/uri-list"<br />

Sets a custom drag image. The setDragImage() method can only be called in response to the dragstart<br />

ev<strong>en</strong>t and only wh<strong>en</strong> an <strong>en</strong>tire HTML elem<strong>en</strong>t is dragged by setting its -webkit-user-drag CSS style to<br />

elem<strong>en</strong>t. The image parameter can be a JavaScript Elem<strong>en</strong>t or Image object.<br />

Bitmap "image/x-vnd.adobe.air.bitmap"<br />

File list "application/x-vnd.adobe.air.file-list"<br />

You can also use other MIME strings, including application-defined strings. However, other applications may not be<br />

able to recognize or use the transferred data. It is your responsibility to add data to the dataTransfer object in the<br />

expected format.<br />

Important: Only code running in the application sandbox can access dropped files. Attempting to read or set any property<br />

of a File object within a non-application sandbox g<strong>en</strong>erates a security error. See “Handling file drops in non-application<br />

HTML sandboxes” on page 621 for more information.<br />

Last updated 6/6/2012<br />

616

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

Saved successfully!

Ooh no, something went wrong!