2 directional Image scroll on mouse _x & _y

I’ve made an image scroller but i can’t get the image to scroll horizontally and vertically the way i want it to.

the image is 1270x710px and the flash movie it’s held in is 640x480

I want the image to scroll depending on where in the movie clip the mouse cursor is.

So far i’ve got it working horizontally only, and diagonally because it’s mixing the horizontal scroll command with the vertical one :frowning:

Here’s the AS used.

this.onMouseMove = function() {
    constrainedMove(bg_mc, 4, 0);
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.destY = Math.round(-((target._height-Stage.height)*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/100));
        } else if (target._x<target.destX) {
            target._x += Math.ceil((target.destX-target._x)*(speed/100));
        if (target._y == target.destY) {
            delete target.onEnterFrame;
        } else if (target._y>target.destY) {
            target._y -= Math.ceil((target._y-target.destY)*(speed/100));
        } else if (target._y<target.destY) {
            target._y += Math.ceil((target.destY-target._y)*(speed/100));

Original FLA can be found here: http://www.optimus-prime.org/imagePan.fla
and SWF can be found here: http://www.optimus-prime.org/imagePan.swf

Thanks in advance for any help you may be able to give me.