# Follow mouse

**URL:** <https://forum.kirupa.com/t/follow-mouse/155815>\
**Category:** Uncategorized\
**Created:** [July 20, 2005, 2:58pm UTC](https://forum.kirupa.com/t/follow-mouse/155815 "2005-07-20T14:58:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![cameron\_](https://avatars.discourse-cdn.com/v4/letter/c/b5ac83/32.png) [@cameron\_](https://forum.kirupa.com/u/cameron_)\
**Post date:** [July 20, 2005, 2:58pm UTC](https://forum.kirupa.com/t/follow-mouse/155815/1 "2005-07-20T14:58:03Z")

</div>

I have a script for an object to follow your mouse, but I want to use it for a menu, and have the object ‘lock on’ to buttons…I have seen it before, does anyone have this offhand?

```auto

 
onClipEvent(load){
 yMin = 10; // _height/2
 yMax = 390; // 400-_height/2
}
onClipEvent(enterFrame){
 if(!this.hitTest(_root._xmouse, _root._ymouse, true)){
	 _y += (_root._ymouse-_y)/15;
 }
 if(_y < yMin){
  _y = yMin;
 }else if(_y > yMax){
  _y = yMax;
 }
}  

```
