# How to drag a movieclip around using mouse

**URL:** <https://forum.kirupa.com/t/how-to-drag-a-movieclip-around-using-mouse/260599>\
**Category:** Uncategorized\
**Created:** [May 17, 2008, 9:04am UTC](https://forum.kirupa.com/t/how-to-drag-a-movieclip-around-using-mouse/260599 "2008-05-17T09:04:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sunjava](https://avatars.discourse-cdn.com/v4/letter/s/94ad74/32.png) [@sunjava](https://forum.kirupa.com/u/sunjava)\
**Post date:** [May 17, 2008, 9:04am UTC](https://forum.kirupa.com/t/how-to-drag-a-movieclip-around-using-mouse/260599/1 "2008-05-17T09:04:09Z")

</div>

i have done so far but i cannot manage to get this work

any help??

\*mouseListener.onMouseDown=function()  
{  
draw=true;  
cubuttonX=\_xmouse;  
cubuttonY=\_ymouse;  
};

mouseListener.onMouseUp=function()  
{  
draw=false;  
}  
mouseListener.onMouseMove= function()  
{  
if(draw)  
{

```
button._x=button._x+(_xmouse-cubuttonX);
button._y=button._y+(_ymouse-cubuttonY);
 
 
}

```

};  
Mouse.addListener(mouseListener);  
\*  
the reason why i did this

```
button._x=button._x+(_xmouse-cubuttonX);
button._y=button._y+(_ymouse-cubuttonY);

```

is that i dont want the movieclip posisiton is at the (0,0) of the mouse

but the code still doesnt work as what i want  
instead, it drag the movieclip too far away…\

---

<div class="post-metadata">

**Author:** ![ajcates](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/ajcates/32/2435_2.png) [@ajcates](https://forum.kirupa.com/u/ajcates)\
**Post date:** [May 17, 2008, 10:11am UTC](https://forum.kirupa.com/t/how-to-drag-a-movieclip-around-using-mouse/260599/2 "2008-05-17T10:11:12Z")

</div>

There is a startDrag and stopDrag functions built into the movieclip class, I would use them, they make dragging movieclips alot easier.

---

<div class="post-metadata">

**Author:** ![sunjava](https://avatars.discourse-cdn.com/v4/letter/s/94ad74/32.png) [@sunjava](https://forum.kirupa.com/u/sunjava)\
**Post date:** [May 17, 2008, 10:41am UTC](https://forum.kirupa.com/t/how-to-drag-a-movieclip-around-using-mouse/260599/3 "2008-05-17T10:41:37Z")

</div>

wow, very straight forwad  
thanks

---

<div class="post-metadata">

**Author:** ![megasxlrm](https://avatars.discourse-cdn.com/v4/letter/m/43a26b/32.png) [@megasxlrm](https://forum.kirupa.com/u/megasxlrm)\
**Post date:** [May 21, 2008, 7:12pm UTC](https://forum.kirupa.com/t/how-to-drag-a-movieclip-around-using-mouse/260599/4 "2008-05-21T19:12:20Z")

</div>

make the movie clip as a button.  
and then code it in the button  
on(press)  
{  
startDrag(this,4 parameters);  
}  
on(release)  
{  
stopDrag();  
}
