views:

48

answers:

2

I am coding a drag and drop application where I can grab an object and then place it over different object containers. When I am dragging the object (keeping the mouse button pressed) and I leave the stage, I can still control the object with the mouse...this is not what I want.

I would like to lose control of the object when the mouse leaves the stage.

I tried to remove the event listener for MOUSE_DOWN on a MOUSE_LEAVE event but nothing.

I also tried to dispatch a MOUSE_UP event on a MOUSE_LEAVE event but it does not work either...it works only if I manually release the mouse button.

Is there any way to override the MOUSE_DOWN event when the user moves the mouse away from the screen but he is still pressing the mouse button??? Any suggestion???

Thanks in advance

A: 

I believe you are talking about the user leaving the flash content altogether with mouse clicked, and when he/she returns it continues the process right?

I suggest, you track the mouse x & y coordinates. Set a condition which triggers the mouse up event handler when the x or y is equal to the stage width or height respectively.

loxxy
I tried to do something like that but the MOUSE_UP event is not triggered if I keep pressing the mouse button down...I guess it is triggered for an instant and then the MOUSE_DOWN event is triggered again...
Mirko
A: 

Is the stage actually listening to the MOUSE_LEAVE event? In any case , check this article, it may help: http://www.kirupa.com/developer/flashcs3/detecting_when_mouse_leaves_movie.htm

PatrickS
Yes, I added an event listener to the stage to listen for a MOUSE_LEAVE...
Mirko
but it is not triggered when I keep pressing the mouse button down.
Mirko
you're right , same thing in the example i've given you. have you tried loxxy's solutions? this should definitely work, dispatch a MouseUp event or get the stage to dispatch a MouseLeave event when the mouse is out of bounds
PatrickS
it works as long as I release the mouse button when I am moving the mouse out of bounds. I set x an y limits therefore my object is stuck by the bounds if I leave the stage but I keep pressing down the mouse button.(it does not disappear like the example)...
Mirko