简体   繁体   中英

Flex 4 Drag-n-Drop with custom DragProxy

I'm doing the drag an drop of an ItemRenderer manually (DataGrid) and want to know how to generate a custom DragProxy of a component that hasn't been added to the display list.

I tried something like this but didn't work:

   private function doDrag(event:MouseEvent):void
   {
    var dragSource:DragSource = new DragSource();
    dragSource.addData(data, 'dnd_format');

    //var bm:Bitmap = new Bitmap(ImageSnapshot.captureBitmapData(this));
    var btn:Button = new Button();
    btn.label = 'New Button';
    var bm:Bitmap = new Bitmap(ImageSnapshot.captureBitmapData(btn));

    var dragProxy:Image = new Image();
    dragProxy.source = bm;
    DragManager.doDrag(this, dragSource, event, dragProxy,0,0, 0.6);
   }

So, I want to be able to create the DragProxy using a component, the button is just an example. Any ideas?

My guess is that this is not working because you are trying to get a bitmap from a component that was just created and has not been added to the stage. I would try testing this code with using an embedded image as the drag proxy first. If that works, then try getting a bitmap from a component that exists on the stage. My guess is that both cases will work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM