How to make a smooth movement (at the end, on release) using drag?
Hello everyone!
I am struggling with the smooth movement of my MC.
I am able to move it around, but want to make it smooth, like google maps or something like that. Right now, it looks very "abrupt" at the end. I am looking for something called drag and throw, i guess. Where when the user releases the mc, it still moves a bit until stops. But i cant use on EnterFrame, since i dont want to keep calling it over and over.
Here is the code that i am using:
Code:
stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
mc_square.addEventListener(MouseEvent.MOUSE_DOWN, start_drag);
mc_square.addEventListener(MouseEvent.MOUSE_UP, stop_drag);
function mouseMoveHandler(evt:MouseEvent):void
{
//Here i have my own cursor.
//mc_my_cursor.x = evt.stageX;
//mc_my_cursor.y = evt.stageY;
}
function start_drag(e:MouseEvent):void
{
mc_square.startDrag();
}
function stop_drag(e:MouseEvent):void
{
mc_square.stopDrag();
}
Any ideas, sugestions, hints, ANYTHING, will be welcome!
Kind regards,
Leo.
When you make changes to the display list in a mouse move handler, you typically want to call updateAfterEvent(). Your custom cursor should move more smoothly if you do that.
At the end of the drag, what I usually do is use a Tween object to move the object to its final position.
Hello Cleong,
Thanks for the reply.
How would u move something at the end of the drag? Isnt that mc already at the end?
I mean, there is no start point, just end point when the user releases the mouse button.
Could u provide an example?
Perhaps I didn't understand you correctly. A typical problem often encounter in drag-and-drop if that we don't want the movie-clip to suddenly appear in the drop slot. Tweening it there makes it look less abrupt.
Thanks Cleong for your reply,
But i still dont understand how can i make a tween without the start point, i just have the end point... and cant use the onEnterFrame..