2
votes

I am looking to implement the drag and drop functionality in flex. I have been able to do that using the drag manager

Drag and drop examples

Only my need is slightly different- I want a copy of the dragged object to be placed, rather than the original object. Any guidance on how to make this possible.

Also, I would like a id to be created dynamically for this dropped object for control. Thanks

2

2 Answers

3
votes

In dragDropHandler call event.preventDefault() - this will disable default drop logic including removal object from the source collection and adding it to the destination collection. Then add your logic.

0
votes

You can override all drag handlers as :

    override protected function dragEnterHandler(event:DragEvent):void{
        if(event.action == DragManager.MOVE)
            event.action=DragManager.COPY;
        super.dragEnterHandler(event);
    }

    override protected function dragCompleteHandler(event:DragEvent):void{
        if(event.action == DragManager.MOVE)
            event.action=DragManager.COPY;
        super.dragCompleteHandler(event);
    }

    override protected function dragDropHandler(event:DragEvent):void{
        if(event.action == DragManager.MOVE)
            event.action=DragManager.COPY;
        super.dragDropHandler(event);
    }

    override protected function dragExitHandler(event:DragEvent):void{
        if(event.action == DragManager.MOVE)
            event.action=DragManager.COPY;
        super.dragExitHandler(event);
    }

    override protected function dragOverHandler(event:DragEvent):void{
        if(event.action == DragManager.MOVE)
            event.action=DragManager.COPY;
        super.dragOverHandler(event);
    }

    override protected function dragStartHandler(event:DragEvent):void{
        if(event.action == DragManager.MOVE)
            event.action=DragManager.COPY;
        super.dragStartHandler(event);
    }