# Mouse Follow Restriction/Position Reset

**URL:** <https://forum.kirupa.com/t/mouse-follow-restriction-position-reset/132039>\
**Category:** Uncategorized\
**Created:** [December 22, 2004, 12:51pm UTC](https://forum.kirupa.com/t/mouse-follow-restriction-position-reset/132039 "2004-12-22T12:51:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jalen](https://avatars.discourse-cdn.com/v4/letter/j/c77e96/32.png) [@jalen](https://forum.kirupa.com/u/jalen)\
**Post date:** [December 22, 2004, 12:51pm UTC](https://forum.kirupa.com/t/mouse-follow-restriction-position-reset/132039/1 "2004-12-22T12:51:51Z")

</div>

gday…  
im newish to flash coding, and am having trouble with a mouse follow that i want to do and am hoping someone can help me out…  
so far ive been able to get my object to follow the mouse around using the following code (logo\_mc is the instance of the object im making follow the mouse):

> logo\_mc.onEnterFrame = function() {  
> var xMouse = \_root.\_xmouse;  
> var yMouse = \_root.\_ymouse;  
> if (Math.abs(xMouse-this.\_x)\<1) {  
> this.\_x = xMouse;  
> this.\_y = yMouse;  
> } else {  
> this.\_x -= (this.\_x-xMouse)/6;  
> this.\_y -= (this.\_y-yMouse)/6;  
> }  
> };

what i want to do, is make it so that once the mouse LEAVES the flash area, the object resets to the center…  
any ideas/theories?
