views:

590

answers:

2

Hello,

I have a Flex Application which displays a collection of items in one of several Lists depending on how the item is classified. By dragging items between the lists, the user kicks off a server side process which attempts to reclassify the items. The server side process then returns some XML which either contains an error message or an 'OK'.

The requirement is for the UI to perform a 'drag move' if the server returns OK and no-op if the server returns an error. Using the default drag handlers (setting dragEnabled=true and dropEnabled=true on the Lists) appears to always perform a drag copy.

As far as I could tell, the only way for me to get enough control over things to handle the asynchrous server validation is to implement dragging to and from the lists manually. So I read Adobe's documentation and attempted to adapt their example.

The problem I am having is that, as far as I can tell, I need to detect dragging by hooking up to the mouseMove event on the List. I then pass the List as the initiator to the DragManager.doDrag routine.

Working in this way has a number of problems: the default proxy image is the size of the entire list, attempting to use the scrollbar sets off a drag detection, etc. Clearly I am doing something wrong.

Has anyone tried implementing drag on Lists manually? Is there a quick trick to detecting drag events correctly? Should I be hunting down the actual itemRenderer the user is dragging and passing that as the initiator?

A: 

Hmmm... if I understand what you're trying to do here, you want to drag an drop, but undo if the server returns an error?

What I would do is to handle the dragEnd event and have that check the server status. If the server had returned an error, then just move the data back to the original list and don't add it to the new list, otherwise just do the default behavior. Feel free to comment about clarifications.

CookieOfFortune
+2  A: 

I'm thinking your drag initiator should be the item renderer that you are dragging rather than the entire List control.

joshtynjala
I just discovered that this works. It's pretty much the only way to mimic the default List drag behavior.
Justin Voshell