I have a function that recognizes the ESC key being pressed. At which point, I want to stop dragging all items.
I”ve tried this.stopDrag() but it wont override the MOUSE_DOWN event.
It there a way to force it to “drop” the item being dragged?
Thanks
stage.addEventListener(KeyboardEvent.KEY_DOWN, escapeKeyDown);
function escapeKeyDown(event : KeyboardEvent):void {
if (event.keyCode == 27) {
trace("ESC");
this.stopDrag();
}
}
Make a global array of all your dragging DisplayObjects:
Then whenever you call startDrag on anything, add it to the array.
Then when you hit ESC, just loop through the array, calling stopDrag on all items, and removing them from the array.
Make sure you also remove the dragging item from the array when you call stopDrag on it from anywhere else.