Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Pesky missing onReleaseOutside... Workarounds?

LEGEND ,
Apr 12, 2011 Apr 12, 2011

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?

TOPICS
ActionScript
964
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 12, 2011 Apr 12, 2011

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 12, 2011 Apr 12, 2011

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 12, 2011 Apr 12, 2011

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 12, 2011 Apr 12, 2011
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines