Posted By

momothemonster on 01/22/11


Tagged

AIR as3 drag-and-drop


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

kure69


AS3 Air Drag and Drop within Robotlegs


 / Published in: ActionScript 3
 

  1. // I Use this within my App Mediator, the view is the Application itself
  2.  
  3. override public function onRegister() : void {
  4. eventMap.mapListener(view, NativeDragEvent.NATIVE_DRAG_ENTER, onDragIn);
  5. eventMap.mapListener(view, NativeDragEvent.NATIVE_DRAG_DROP, onDragDrop);
  6. }
  7.  
  8. private function onDragIn(event:NativeDragEvent) : void {
  9. var url : String = event.clipboard.getData( ClipboardFormats.URL_FORMAT ) as String;
  10. var files : Array = event.clipboard.getData( ClipboardFormats.FILE_LIST_FORMAT ) as Array;
  11.  
  12. if( ( files != null && files.length >= 0 ) || ( url != null ) ){
  13. NativeDragManager.acceptDragDrop(contextView);
  14. }
  15. }
  16.  
  17. private function onDragDrop(event:NativeDragEvent):void {
  18. var files : Array = event.clipboard.getData( ClipboardFormats.FILE_LIST_FORMAT ) as Array;
  19. var file:File = files[0];
  20. if( file.url != null ){
  21. dispatch(new SystemEvent(SystemEvent.LOAD_FILE, file.url));
  22. }
  23. }

Report this snippet  

You need to login to post a comment.