# Help - Making obj ease opposite direction of mouse

**URL:** https://forum.kirupa.com/t/help-making-obj-ease-opposite-direction-of-mouse/222754
**Category:** flash
**Created:** [April 16, 2007, 6:42pm UTC](https://forum.kirupa.com/t/help-making-obj-ease-opposite-direction-of-mouse/222754 "2007-04-16T18:42:30Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![DragnRidr85](https://avatars.discourse-cdn.com/v4/letter/d/a183cd/32.png) [@DragnRidr85](https://forum.kirupa.com/u/DragnRidr85)
#### Post date: [April 16, 2007, 6:42pm UTC](https://forum.kirupa.com/t/help-making-obj-ease-opposite-direction-of-mouse/222754/1 "2007-04-16T18:42:30Z")

</div>

Hi. I am trying to make a movieclip (or any object, button, graphic) ease into the opposite direction that my mouse is moving. I have figure out how to do this. I am using the following code applied to the object’s action (thanks to some help from a previous post):

onClipEvent (load) {  
\_x = 0;  
\_y = 0;  
speed = 13;  
}  
onClipEvent (enterFrame) {  
endX = Stage.width-\_root.\_xmouse;  
endY = Stage.height-\_root.\_ymouse;  
\_x = \_x +(endX-\_x)/speed;  
\_y = \_y +(endY-\_y)/speed;  
}

My question is however: Look at this following link. You will see how when the mouse is moved the pictures move opposite, but for a limited distance. (they don’t go off the screen like they would with the code i posted above). How can I limit the movement of the pictures so it won’t go off the screen and only have it move opposite in a limited area? I’ve tried a lot of manipulation of the code and read many tutorials :book: but cannot figure it out Ⓜ

the link is [http://www.templatehelp.com/preset/pr\_preview.php?i=13916&pr\_code=uf18Ez8fJ7QATk21NsHRg3Ag6uS738](http://www.templatehelp.com/preset/pr_preview.php?i=13916&pr_code=uf18Ez8fJ7QATk21NsHRg3Ag6uS738)

I would greatly appreciate any help. Thanks!
