Monday, October 18, 2010

Frustrating Flex problems solved #7 - Removing DragDrop animation

In Flex was building a simple drag and drop from a library list to another simple list. I also wanted to build the functionality of dragging the item out of the simple list to automatically remove the item from the list, and return the item to the library.

I managed to handle this with one problem remaining. As the dragged item thought it wasn't going to be accepted, it automatically played an animation of it returning to the simple list before my code displayed it back in the library. The animation was completely misleading but I couldn't find a way to turn it off!

My solution in the end was to create a custom ListItemDragProxy component. I included this in the list with:
dragIndicatorClass="display.CustomListItemDragProxy"

and in the custom class, I merely set visible=0 onMouseUp. Simple solution that works perfectly.