# Mouse follow help

**URL:** <https://forum.kirupa.com/t/mouse-follow-help/18395>\
**Category:** Uncategorized\
**Created:** [April 16, 2003, 9:11am UTC](https://forum.kirupa.com/t/mouse-follow-help/18395 "2003-04-16T09:11:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![syssan](https://avatars.discourse-cdn.com/v4/letter/s/77aa72/32.png) [@syssan](https://forum.kirupa.com/u/syssan)\
**Post date:** [April 16, 2003, 9:11am UTC](https://forum.kirupa.com/t/mouse-follow-help/18395/1 "2003-04-16T09:11:43Z")

</div>

I want the mouse to follow a certain object in my movie.  
any help?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 16, 2003, 10:09am UTC](https://forum.kirupa.com/t/mouse-follow-help/18395/2 "2003-04-16T10:09:00Z")

</div>

on the object, put the code:

[AS]  
onClipEvent (enterFrame) {  
this.\_x = \_root.\_xmouse  
this.\_y = \_root.\_ymouse  
}  
[/AS]

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 16, 2003, 1:53pm UTC](https://forum.kirupa.com/t/mouse-follow-help/18395/3 "2003-04-16T13:53:44Z")

</div>

thx, but i want the object to move and the mouse to follow…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 16, 2003, 2:05pm UTC](https://forum.kirupa.com/t/mouse-follow-help/18395/4 "2003-04-16T14:05:59Z")

</div>

Hi,  
As far as I know you cannot make the mouse follow anything as its movement is user controlled, however you can create the illusion of the mouse following an object by moving the object in front of the mouse, adjust blah de blah’s code like this :  
[AS]onClipEvent (enterFrame) {  
this.\_x = \_root.\_xmouse-50  
this.\_y = \_root.\_ymouse-50  
}[/AS]

This will keep the object 50 pixels in front of the mouse

Hope it helps

SteveD
