Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flex DRAG_DROP Event - Is it possible to access the Image Being Dragged?

When you start a Flex drag action, you pass in a proxy image to be displayed when you drag across the screen. When the drop occurs, I want to be able to grab this proxy but I can't find a way to from the DragEvent object.

Is it possible? What I want is to actually drop the dragged image when the mouse button is released... Flex automatically does a nice shrinking animation on the proxy but I don't want that.

The Flex examples show what I don't want - the proxy is removed and a new image added but not in exactly the right place...

More info: I tried adding my Proxy Image as a data item to the DragSource. I was able to access this when the drop occurred and saw there is a class mx.managers.dragClasses.DragProxy which seems to have all the info I need... but this class is not documented?

So there's two questions really... how to get the proxy and find out the position of the mouse cursor within the proxy, and how to disable the Flex drop animation.

like image 521
MidnightGun Avatar asked Dec 12 '25 03:12

MidnightGun


2 Answers

The dragProxy is a static getter on the DragManager and is scoped to mx_internal. So to reference it, you'd have to do something like this:

import mx_internal;

And in a drag event handler:

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

I'm not sure how you could prevent the animation. If I find out, I'll let you know.

like image 126
Christophe Herreman Avatar answered Dec 16 '25 06:12

Christophe Herreman


For disabling the animation in the s:List, in a dragCompleteHandler override, you can 'hack' into the DragManager to get the dragProxy and hide it.

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

Probably applicable in other situations.

like image 22
Slain Avatar answered Dec 16 '25 06:12

Slain



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!