A diary about programming problems - to help me more easily learn from (and Google) past mistakes.
Showing posts with label drag. Show all posts
Showing posts with label drag. Show all posts
Friday, 15 March 2013
EaselJS: EASY Drag Method
I have seen an example of a drag method, which used an offset object that constantly calculated the difference between the position of the mouse and the position of the initial click, I think. But this is way easier.
1) The mousemove event listener has to be added to the mousedown event in order to work.
2) Position the object using the stageX and Y properties of the mousemove event.
3) Be sure to update the stage!
A mouse up event occurs when you release the mouse, so if you need something to occur then, add a mouseup event listener to the mousedown event.
EDIT: I came across this method somewhere else later - oh well, I guess I'm not a programming genius...
Subscribe to:
Posts (Atom)
