Move left and right with mouse

Hi Can anyone help me with moving a image left and right depending on the mouse position like the following…

I had the following…

// now i need the mouse to move

mspeed = 5
endX = _root._xmouse;
_x += (endX-_x)/mspeed;

But the image just follows the mouse, ideally I need it to keep on moving left or right (unless the mouse is in the center) any help please?