Skip to main content
Inspiring
March 26, 2009
Question

Keeping my Mouse in the Same Rectangle as the startDrag

  • March 26, 2009
  • 4 replies
  • 892 views
I am noticing that if you let the mouse wonder away from the movie clip while dragging, it doesn't drop when you let go of the button. You have to click in the defined rectangle for the drag for the movie clip to drop appropriately.

How can I define my mouse movement to the same rectangle as the drag while the movie is clicked on and being dragged?

Thank you.

Dave
This topic has been closed for replies.

4 replies

Inspiring
March 29, 2009
Can we revisit this issue? If I set all of my MOUSE_UP's to stage, they are all executing when the MOUSE_UP event is fired and it is obviously causing code problems.

How do you only have it run the code that is associated with the MOUSE_UP for the item you have just quit dragging (i.e. stopDrag();).

Thanks.

Dave
Inspiring
March 29, 2009
What code problems does it cause?
Inspiring
March 29, 2009
I have 4 items on the screen that can be dragged. If I use stage for all of them for MOUSE_UP, it looks like the function is running for each one when the mouse is released; which makes sense because the are all being told to execute on a MOUSE_UP.

Obviously I want different things to happen depending on what was dragged and where it is dropped so each MOUSE_UP / stopDrag() function will be different.

Any thoughts?

Thanks.

Dave
Inspiring
March 26, 2009
Thanks guys...that definitely worked.
Inspiring
March 26, 2009
You need to add event listener MouseEvent.MOUSE_UP to stage - not to the object - this way drag will stop no matter over which object MOUSE_UP occurs.
Inspiring
March 26, 2009
You cannot restrain the movement of the mouse in Flash.
I think you are looking for code to 'drop' the dragged item also when mousebutton released outside of that object.

instead of having the object listen to the MOUSE_UP event to drop the object, have the stage listen for that event. Wherever you release the mouse, it will be over the stage thus dropping the item.