Help - Making obj ease opposite direction of mouse

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 :m:

the link is http://www.templatehelp.com/preset/pr_preview.php?i=13916&pr_code=uf18Ez8fJ7QATk21NsHRg3Ag6uS738

I would greatly appreciate any help. Thanks!