Pan Image Fail

Dear People,

I’m still a bit of a noob in Action Script, but i found this script on the internet that seems to work pretty well.

I made this website: www.biezenkuilen.nl/speeltuin which has a pan script in it. The problem: When you scroll to the most far right corner it first works but if you try a second time you will scroll into a white area, which i didn’t put there. Somehow it finished my picture and therefore showing the part of my stage, which is empty white space. Obviously i want to picture to stop panning when the end is reached and no further. Can someone help me with this problem. I have no clue what to do…:slight_smile:

Thanks in advance.

Kind regards,

teddy

The script i used is:

constrainedMove(bg_mc, 2, 1);

function constrainedMove(target:MovieClip, speed:Number, dir:int){
var mousePercent:Number = mouseX / stage.stageWidth;

stage.addEventListener(MouseEvent.MOUSE_MOVE, panImage);
target.cacheAsBitmap = true;

function panImage(E:MouseEvent):void {
    var mSpeed:Number;
    mousePercent = mouseX / stage.stageWidth;
    if (dir == 1) {
        mSpeed = mousePercent;
    } else {
        mSpeed = 1 - mousePercent;
    }
    target.destX = Math.round(-((target.width - stage.stageWidth) * mSpeed));
    if(target.hasEventListener(Event.ENTER_FRAME)){
        target.removeEventListener(Event.ENTER_FRAME, del);
    }
    target.addEventListener(Event.ENTER_FRAME, del);
    E.updateAfterEvent();
}

function del(E:Event):void {
    if (Math.abs(target.x - target.destX) <= 1) {
        target.x = Math.round(target.destX);
        target.removeEventListener(Event.ENTER_FRAME, arguments.callee);
    } else {
        target.x += (target.destX - target.x) * (speed / 100);
    }
}

}