# Moving and stopping it with mouse movements

**URL:** <https://forum.kirupa.com/t/moving-and-stopping-it-with-mouse-movements/261822>\
**Category:** Uncategorized\
**Created:** [May 31, 2008, 9:46am UTC](https://forum.kirupa.com/t/moving-and-stopping-it-with-mouse-movements/261822 "2008-05-31T09:46:46Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![cgfullmoon](https://avatars.discourse-cdn.com/v4/letter/c/f4b2a3/32.png) [@cgfullmoon](https://forum.kirupa.com/u/cgfullmoon)\
**Post date:** [May 31, 2008, 9:46am UTC](https://forum.kirupa.com/t/moving-and-stopping-it-with-mouse-movements/261822/1 "2008-05-31T09:46:46Z")

</div>

Hello,  
I am trying to create time-line that moves in the direction of the mouse movement but then will stop whenever I hover over an area. In other words, I have links on the time-line that I want to be able to stop at by hovering over the button. The code listed below is what I am using for the x and y background movements:  
(What am I missing to get the background to stop when I hover over a button?)

this.onMouseMove = function() {

constrainedMove(bg2\_mc, 4, 1);

};  
function constrainedMove(target:MovieClip, speed:Number, dir:Number) {

var mousePercent:Number = \_xmouse/Stage.width;  
var mSpeed:Number;  
if (dir == 1) {

mSpeed = 1-mousePercent;

} else {

mSpeed = mousePercent;

}  
target.destX = Math.round(-((target.\_width-Stage.width)\*mSpeed));  
target.onEnterFrame = function() {

if (target.\_x == target.destX) {

delete target.onEnterFrame;

} else {

target.\_x += Math.ceil((target.destX-target.\_x)\*(speed/300));

}

};

}
