Drag and drop in AIR
snipped by ankurpatel18
This is used to drag and drop the image only jpg for this example.
For use this code you justhave to add UILoader component on screen, name it "uildr". so and paste this code on first frame. also add new bottom new layer and add movie clip with name in library "hit" and it same as stage size.
import flash.desktop.NativeDragManager; import flash.events.NativeDragEvent; import flash.desktop.ClipboardFormats; this.addEventListener(NativeDragEvent.NATIVE_DRAG_ENTER,onDragEnter); this.addEventListener(NativeDragEvent.NATIVE_DRAG_ENTER,onDragDrop); function onDragEnter (e:NativeDragEvent):void { var fa:Object = e.clipboard.getData(ClipboardFormats.FILE_LIST_FORMAT); if (fa[0].extension == "jpg") { NativeDragManager.acceptDragDrop(this); } } function onDragDrop (e:NativeDragEvent):void { var fa:Object = e.clipboard.getData(ClipboardFormats.FILE_LIST_FORMAT); uildr.source = fa[0].url; }




