Reputation: 2212
I'm trying to 2D "camera" movement (really just adjusting the x,y of the background image) when a user holds down the mouse button and moves the mouse.
I know the MouseEvent.MOUSE_MOVE exists, and mouse click events exist, but I'm not sure how to correctly combine these events for only working while the mouse is depressed and the mouse is moving.
Thanks for the help!
Upvotes: 1
Views: 841
Reputation: 115
There´s a good tut on this here: http://edutechwiki.unige.ch/en/Flash_drag_and_drop_tutorial
Complete with source code and all.
Upvotes: 0
Reputation: 19748
You need to use a combination of MouseEvent.MOUSE_DOWN, MouseEvent.MOUSE_UP, and MouseEvent.MOUSE_MOVE, I'd also have variables for saving the position of the background when the mouse down happens and for storing the mouse position when the mouse down happens (then add or remove the MOUSE_MOVE listener using the MOUSE_DOWN and MOUSE_UP event handlers). You probably also want to handle ROLL_OUT and have it call the MOUSE_UP handler.
Upvotes: 1