# Help with drag problem

**URL:** <https://forum.kirupa.com/t/help-with-drag-problem/209264>\
**Category:** flash\
**Created:** [December 7, 2006, 9:50am UTC](https://forum.kirupa.com/t/help-with-drag-problem/209264 "2006-12-07T09:50:32Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bill\_Blast](https://avatars.discourse-cdn.com/v4/letter/b/b38774/32.png) [@Bill\_Blast](https://forum.kirupa.com/u/Bill_Blast)\
**Post date:** [December 7, 2006, 9:50am UTC](https://forum.kirupa.com/t/help-with-drag-problem/209264/1 "2006-12-07T09:50:32Z")

</div>

I’m using this piece of code to drag a movie around the stage and ease out on release. It works great except that everytime I press the mouse down, the movie won’t drag until it has first aligned the \_xmouse and \_ymouse position with the centre of the mc (the mc I’m dragging has large dimensions meaning I get amn annoying movement before it drags). I just want to be able to drag the mc from where ever I click on it.

\_root.myMC.ease = 2;  
\_root.myMC.onPress = function() {  
this.drag = true;  
}  
\_root.myMC.onEnterFrame = function() {  
if (this.drag == true) {  
this.targX = \_root.\_xmouse;  
this.targY = \_root.\_ymouse;  
}  
if (this.\_x != this.targX | this.\_y != this.targY) {  
this.\_x += (this.targX-this.\_x)/this.ease;  
this.\_y += (this.targY-this.\_y)/this.ease;  
}  
}  
\_root.myMC.onMouseUp = function() {  
this.drag = false;  
}

I thought about doing it like this but this does not give me the easing effect I require.

\_root.myMC.onPress = function() {  
this.startDrag(false);  
}  
\_root.myMC.onRelease = function() {  
stopDrag();  
}

I’m attaching the file.

Is there anyone out there that can help me?

Thanks.
