Interactive Image Panning Tutorial

Hi folks,

I’ve searched for something on this topic already, but haven’t quite found what I’m looking for.

I’m doing the Interactive image panning tutorial, and was wondering is there any way of making the mouse pan both the X and Y axis ? (as opposed to just the x) I tried adding another statement for the y axis at the bottom, but it doesn’t work properly.


this.onMouseMove = function() {
	constrainedMove(bg_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 if (target._x>target.destX) {
			target._x -= Math.ceil((target._x-target.destX)*(speed/50));
		} else if (target._x<target.destX) {
			target._x += Math.ceil((target.destX-target._x)*(speed/50));
		}
	};
		target.destY = Math.round(-((target._width-Stage.width)*mSpeed));
	target.onEnterFrame = function() {
		if (target._Y == target.destY) {
			delete target.onEnterFrame;
		} else if (target._y>target.destY) {
			target._y -= Math.ceil((target._y-target.destY)*(speed/50));
		} else if (target._y<target.destY) {
			target._y += Math.ceil((target.destY-target._y)*(speed/50));
		}
	};
	

}

Any ideas how to combine both the X and Y axis within the actionscript ?

Thanks.

Aaron