Flex event DRAG_DROP - is it possible to access image movement?

When you run the Flex drag action, you send a proxy image that will be displayed when you drag it around the screen. When a crash occurs, I want to be able to capture this proxy, but I can not find a way from the DragEvent object.

Is it possible? What I want is to actually pull out the dragged image when releasing the mouse button ... Flex automatically performs a nice cut animation on the proxy, but I don't want that.

Flex examples show that I do not want - the proxy is deleted and a new image is added, but not in the right place ...

Additional Information: I tried to add my proxy image as a data item in DragSource. I was able to access this when an error occurred, and saw that there is a class mx.managers.dragClasses.DragProxy that seems to have all the information I need ... but this class is not documented?

So, there are two questions ... how to get the proxy server and find out the position of the mouse cursor in the proxy server and how to disable the Flex frame transfer animation.

+3
source share
9 answers

DragProxy is a static getter in the DragManager and is limited to mx_internal. Therefore, to reference this, you need to do something like this:

import mx_internal;

And in the drag event handler:

var p:* = DragManager.mx_internal::dragProxy;

I'm not sure how animation can be prevented. If I find out, I'll let you know.

+2

s: List, dragCompleteHandler "" DragManager, dragProxy .

override protected function dragCompleteHandler(e:DragEvent):void
{
  DragManager.mx_internal::dragProxy.visible = false; // <- MAGIC!
  super.dragCompleteHandler(e);
}

, .

+2

:

- DragProxy (.. , ) mouseUpHandler().

, , ​​ Adobe .

+1

, - , :

, . , e.currentTarget.contentMouseX e.currentTarget.contentMouseY . dragSource ( ), :

var drgSrc:DragSource = new DragSource();
drgSrc.addData( { x:e.currentTarget.contentMouseX, y:e.currentTarget.contentMouseY }, 'drgXY' );

( , drpCvs):

var newImg:Image = new Image();
newImg.x = drpCvs.contentMouseX - e.dragSource.dataForFormat( 'drgXY' ).x;
newImg.y = drpCvs.contentMouseY - e.dragSource.dataForFormat( 'drgXY' ).y;

, , . , RTF.

+1

, () : - MOUSE_UP, - false. , . - :

var proxy:UIComponent = new UIComponent();
proxy.graphics.lineStyle(1);
proxy.graphics.beginFill(0xccddff);
proxy.graphics.drawRect(0, 0, main.width, main.height);
stage.addEventListener(MouseEvent.MOUSE_UP, function (e:MouseEvent):void {
  proxy.visible = false;
});
0

@ykessler: , . SDK: DragProxy.as

@: , . , .

0

, MouseUp-Handler SandboxRoot MouseUp-Handler dragEnterHandler , :

protected function dragEnterHandler(event:DragEvent):void{

        DragManager.acceptDragDrop(this);

        this.dragProxy = DragManager.mx_internal::dragProxy;// get drag proxy

        var sm:ISystemManager = event.dragInitiator.systemManager.topLevelSystemManager as ISystemManager;
        var ed:IEventDispatcher = sm.getSandboxRoot();
        this.sandboxRoot = sm.getSandboxRoot();
        //remove
        ed.removeEventListener(MouseEvent.MOUSE_UP, dragProxy.mouseUpHandler, true);

        //attach own
        ed.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler, true);
        ed.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);

        this.dragInitiator = event.dragInitiator;}

mouseUpHandler mouseUpHandler DragProxy.as Drop-Effect.

0

, visible = 0 onMouseUp ListItemDragProxy.

0

event.dragInitiator.visible = false;

!

0

Source: https://habr.com/ru/post/1698468/


All Articles