Copy link to clipboard
Copied
Hey all,
I'm dragging a lot of clips around and sometimes I get the pesky issue where the MOUSE_UP event does fire properly and the clip is stuck to the mouse, not having the stopDrag() run because the event failed to fire.
In my case I'm dragging a sprite that's restricted to vertical scrolling. This sprite has a mask applied to it. I click on a part of the sprite, it startDrags(), my mouse goes outside the masked area and at that point no MOUSE_UP event will fire.
This used to happen in AS2 a ton and you just used onReleaseOutside to make sure that the event fired. Where the heck is this for AS3? That was built specifically so when someone clicks on something inside a flash app, moves their mouse outside the flash app and lets go, flash is still guaranteed to get an event that the mouse went up. What's the equivalent to this in AS3?
Copy link to clipboard
Copied
Hi
Add a listener to the stage to capture the MOUSE_UP event outside of your drag item, imitates the onReleaseOutside event.
stage.addEventListener(MouseEvent.MOUSE_UP, stopDragFunction, false, 0, true);
Works everytime.
Copy link to clipboard
Copied
Unfortunately it's very important to me to know which item the MOUSE_UP came from. Are you suggesting it would be standard practice to make a holder variable to indicate which item was originally clicked so when stage MOUSE_UP occurs I'll have a way of knowing what was originally clicked?
Copy link to clipboard
Copied
Hi
I'm not suggesting this is standard practice, but I have used this method of holding a reference to a clicked/dragged item for later use.
Such as event processing or for getter/setter and cross-class linking.
Copy link to clipboard
Copied
I'm definitely looking for a best practice on this because it's a typical enough issue that they created onReleaseOutside in AS2 just to combat the fact that sometimes things are dragged beyond bounds, whether they be a mask or the flash app itself. There must be a best practice replacement for onReleaseOutside..
Thanks for confirming you've done this before. I don't want to cruft anything.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more