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

Drag effects in HTML<br />

Adobe AIR 1.0 and later<br />

The initiator of the drag gesture can limit the allowed drag effects by setting the dataTransfer.effectAllowed<br />

property in the handler for the dragstart ev<strong>en</strong>t. The following string values can be used:<br />

String value Description<br />

"none" No drag operations are allowed.<br />

"copy" The data will be copied to the destination, leaving the original in place.<br />

"link" The data will be shared with the drop destination using a link back to the original.<br />

"move” The data will be copied to the destination and removed from the original location.<br />

"copyLink" The data can be copied or linked.<br />

"copyMove" The data can be copied or moved.<br />

"linkMove" The data can be linked or moved.<br />

"all" The data can be copied, moved, or linked. All is the default effect wh<strong>en</strong> you prev<strong>en</strong>t the default behavior.<br />

The target of the drag gesture can set the dataTransfer.dropEffect property to indicate the action that is tak<strong>en</strong> if<br />

the user completes the drop. If the drop effect is one of the allowed actions, th<strong>en</strong> the system displays the appropriate<br />

copy, move, or link cursor. If not, th<strong>en</strong> the system displays the unavailable cursor. If no drop effect is set by the target,<br />

the user can choose from the allowed actions with the modifier keys.<br />

Set the dropEffect value in the handlers for both the dragover and drag<strong>en</strong>ter ev<strong>en</strong>ts:<br />

function doDragStart(ev<strong>en</strong>t) {<br />

ev<strong>en</strong>t.dataTransfer.setData("text/plain","Text to drag");<br />

ev<strong>en</strong>t.dataTransfer.effectAllowed = "copyMove";<br />

}<br />

function doDragOver(ev<strong>en</strong>t) {<br />

ev<strong>en</strong>t.dataTransfer.dropEffect = "copy";<br />

}<br />

function doDragEnter(ev<strong>en</strong>t) {<br />

ev<strong>en</strong>t.dataTransfer.dropEffect = "copy";<br />

}<br />

Note: Although you should always set the dropEffect property in the handler for drag<strong>en</strong>ter, be aware that the next<br />

dragover ev<strong>en</strong>t resets the property to its default value. Set dropEffect in response to both ev<strong>en</strong>ts.<br />

Dragging data out of an HTML elem<strong>en</strong>t<br />

Adobe AIR 1.0 and later<br />

The default behavior allows most cont<strong>en</strong>t in an HTML page to be copied by dragging. You can control the cont<strong>en</strong>t<br />

allowed to be dragged using CSS properties -webkit-user-select and -webkit-user-drag.<br />

Override the default drag-out behavior in the handler for the dragstart ev<strong>en</strong>t. Call the setData() method of the<br />

dataTransfer property of the ev<strong>en</strong>t object to put your own data into the drag gesture.<br />

Last updated 6/6/2012<br />

617

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

Saved successfully!

Ooh no, something went wrong!