AS3 Air Drag and Drop within Robotlegs


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



Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.