0 Replies Latest reply on Jan 28, 2011 7:02 AM by embinder

    List DragDrop

    embinder

      I have an AIR app with a list. I want to be able to drag items from  the list to the desktop but also would like to maintain the ability to  dragMove the items in the list. The native dragStart for a list will  allow the dragMove which is great, but when I add my own code in a  DRAG_START listener for copying the file to the computer it loses that  functionality.

       

       

      What I thought made the most sense was to actually have my code for  copying the files in a DRAG_EXIT listener, though that doesn't seem to  be the answer. Even though the function is called the new  NativeDragManager.doDrag() does not seem to work.

       

                  private function onDragStart(e:DragEvent):void
                 
      {
                     
      var volumes:Vector.<StorageVolume> = StorageVolumeInfo.storageVolumeInfo.getStorageVolumes();
                     
      var driveFound:Boolean;
                     
      var flashDrive:StorageVolume;

                     
      for each (var vol:StorageVolume in volumes)
                     
      {
                         
      if (vol.name == Constants.FLASH_DRIVE_NAME)
                         
      {
                              driveFound
      = true;
                              flashDrive
      = vol;
                         
      }
                     
      }

                     
      if (driveFound)
                     
      {
                         
      var drivePath:String = flashDrive.rootDirectory.nativePath;
                         
      var drivePathLastChar:String = drivePath.charAt(drivePath.length - 1);
                         
      if (drivePathLastChar != "/" || drivePathLastChar != "\\") drivePath = drivePath + "/";

                         
      var transfer:Clipboard = new Clipboard();
                         
      var files:Array = [];

                         
      for each (var a:Object in favoritesList.selectedItems)
                         
      {
                             
      var file:File = new File(drivePath + a.location + a.mattelId + "." + a.fileType);
                              files
      .push(file);
                         
      }

                          transfer
      .setData(ClipboardFormats.FILE_LIST_FORMAT, files, false);

                         
      var dragOptions:NativeDragOptions = new NativeDragOptions();
                          dragOptions
      .allowMove = true;
                          dragOptions
      .allowCopy = true;
                          dragOptions
      .allowLink = false;

                         
      NativeDragManager.doDrag(this, transfer, null, null, dragOptions);
                     
      }
                     
      else
                     
      {
                         
      Alert.show("Please insert your Flash Drive");
                     
      }
                 
      }

       

      The previous code is what I am using to copy the files to the system.  It works as it should, though I then lose the dragMove() functionality.  Any thoughts?

       

       

      Thanks!