0 Replies Latest reply on Apr 6, 2012 5:44 AM by Toto RoToTO

    [MAC OS X - Illustrator CS5.1] DragDrop between Illustrator and Extension

    Toto RoToTO Level 3



      What I would like to achieve is to handle Drag and Drop between Illustrator and Creative suite extension (specially from Illustrator to extension, designed for Illustrator).


      I would like to get a reference or a pointer on the selection / objects dropped on my extension, and then do something with the selection / objects dropped in my ex extension. Pretty much like they did in the Symbol swatch.



      So, here it is the code implemented (in my POC extension):




      // Called when the user moves the drag proxy onto the drop target.
      private function dragEnterHandler(event:DragEvent):void 
           // Accept the drag only if the user is dragging data 
           // identified by the 'color' format value.
           if (event.dragSource.hasFormat('air:bitmap')) 
                  // Get the drop target component from the event object.
                  var dropTarget:Canvas=Canvas(event.currentTarget);
                  // Accept the drop.
      // Called if the target accepts the dragged object and the user 
      // releases the mouse button while over the Canvas container. 
      private function dragDropHandler(event:DragEvent):void
                  //Only Image available?
                    var data:Object = event.dragSource.dataForFormat('air:bitmap');
                     //Test: Quick and Dirty!!
                   var data2:BitmapData = data as BitmapData;
                     var myBitmap:Bitmap = new Bitmap(data2);






                          <mx:Image id="myImage" width="100" height="100"/>



      It works. But right now, the only available in the Dragsource object is a bitmap.

      I've used the debugger to check if I could find something else, but I did not.


      I have also tried to use the NativeDragManager. But it is pretty much the same.


      I'm stuck.

      Anyone could help me?

      Does anyone know if it is possible to retrieve something else than a bitmap form the dragsource object?


      So any help would be appreciated.