# Very optimized "follow mouse"-thing

**URL:** https://forum.kirupa.com/t/very-optimized-follow-mouse-thing/196373
**Category:** open source
**Created:** [August 7, 2006, 10:51pm UTC](https://forum.kirupa.com/t/very-optimized-follow-mouse-thing/196373 "2006-08-07T22:51:38Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Pattt](https://avatars.discourse-cdn.com/v4/letter/p/f1d935/32.png) [@Pattt](https://forum.kirupa.com/u/Pattt)
#### Post date: [August 7, 2006, 10:51pm UTC](https://forum.kirupa.com/t/very-optimized-follow-mouse-thing/196373/1 "2006-08-07T22:51:38Z")

</div>

I just made a code that makes an mc following the mouse! 🙂  
Put this in the mc’s action and see the result! 🙂  
And put the framerate to 30-120 or something for smooth movements. 😃

```auto
onClipEvent (load) {
 var wait_time = 50, a = new Array();
}
onClipEvent (enterFrame) {
 a[a.length] = [_root._xmouse, _root._ymouse];
 _x=a[a.length-wait_time][0], _y=a[a.length-wait_time][1];
}

```
