[Flash CS3 AS2] Problem with motion based on _xmouse

Hi All,

So I’m stuck and going nuts. I need to move a movieclip based on mouse x position. Like this site http://annieegiancasting.com/ - Which I built using a flashloaded app, but I need more control in this project so I’d like to code it without the app.

Basically, I have an image of a boy (left) and a girl (right) and I want to move the boy slightly toward the girl when the mouse goes right and slightly away when the mouse goes left. But only about 25-50 pixels in each direction.

I’ve cobbled some code together from google searching and rough ideas, and it works in a way, but the boy jumps about 400 pixels to the left on the initial mouse move and then floats a bit too far right and left from there.

Here’s what I’ve got on the boyMC:

onClipEvent (enterFrame) {
	MouseX = (_root._xmouse);
	thisX = this._x;
	diffX = MouseX - thisX;
	moveX = diffX / 30;
	this._x = thisX + moveX;
}

The movement has a nice ease to it and does roughly what I want but something is missing. Any help on this would be greatly, greatly appreciated. Thanks in advance!!