onReleaseOutside in AS3

There is no onReleaseOutside call in AS3. So, to get that, the best way is to, when your MOUSE_DOWN event function is called, to add a MOUSE_UP event listener to the stage. Then remove that listener when the event is triggered.

eg.

myBtn.addEventListener(MouseEvent.MOUSE_DOWN, downHandler):

function downHandler(event:MouseEvent):void
{
  stage.addEventListener(MouseEvent.MOUSE_UP, upHandler);
  // do whatever on mouseDown eg. startDrag()
}
function upHandler(event:MouseEvent):void
{
  stage.removeEventListener(MouseEvent.MOUSE_UP, upHandler);
  // do whatever eg. stopDrag();
}
Tech Reference:

Leave a Reply

Your email address will not be published. Required fields are marked *

Proudly powered by WordPress | Theme: Baskerville 2 by Anders Noren.

Up ↑