Drag and Drop in AIR


/ Published in: ActionScript 3
Save to your folder(s)



Copy this code and paste it in your HTML
  1. import flash.desktop.NativeDragManager;
  2. import flash.events.NativeDragEvent;
  3. import flash.desktop.ClipboardFormats;
  4.  
  5. this.addEventListener(NativeDragEvent.NATIVE_DRAG_ENTER,onDragEnter);
  6. this.addEventListener(NativeDragEvent.NATIVE_DRAG_ENTER,onDragDrop);
  7.  
  8. function onDragEnter (e:NativeDragEvent):void {
  9. var fa:Object = e.clipboard.getData(ClipboardFormats.FILE_LIST_FORMAT);
  10. if (fa[0].extension == "jpg") {
  11. NativeDragManager.acceptDragDrop(this);
  12. }
  13. }
  14.  
  15. function onDragDrop (e:NativeDragEvent):void {
  16. var fa:Object = e.clipboard.getData(ClipboardFormats.FILE_LIST_FORMAT);
  17. uildr.source = fa[0].url;
  18. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.