Weird Bug with Horizontal Scrollbar, Help Please!

I’ve been playing around with claudio’s scrollbar, and I managed to find a similar one that worked horizontally. The drag/scrolltrack part works perfectly, but the left/right buttons seem to lack boundaries. If you roll over them, they just scroll off into infinity. I’m not a master of Flash or anything, and I just cannot seem to figure out what I need to do. Please help!

Here is the actionscript I’m using:


space = 750;
friction = 2;
speed = 4;
xD = dragger._x;
top = main._x;
bottom = main._x+mask_mc._width- 9785 -space;
dragger.onPress = function() {
    drag = true;
    this.startDrag(false, this._parent.xD+this._parent.bar._width-this._width, this._y, this._parent.xD, this._y);
    dragger.scrollEase();
};
dragger.onMouseUp = function() {
    this.stopDrag();
    drag = false;
};
bar.onPress = function() {
    drag = true;
    if (this._parent._xmouse>this._x+this._width-this._parent.dragger._width) {
        this._parent.dragger._x = this._parent._xmouse;
        this._parent.dragger._x = this._x+this._width-this._parent.dragger._width;
    } else {
        this._parent.dragger._x = this._parent._xmouse;
    }
    dragger.scrollEase();
};
bar.onMouseUp = function() {
    drag = false;
};
moveDragger = function (d) {
    if ((dragger._x>=xD+bar._width-dragger._width && d == 1) || (dragger._x<=xD && d == -1)) {
        clearInterval(myInterval);
    } else {
        dragger._x += d;
        dragger.scrollEase();
        updateAfterEvent();
    }
};
up_btn.onRollOver = function() {
    myInterval = setInterval(moveDragger, 0, -.1);
};
down_btn.onRollOver = function() {
    myInterval = setInterval(moveDragger, 0, .1);
};
up_btn.onRollOut = down_btn.onRollOut=function () {
    clearInterval(myInterval);
};
MovieClip.prototype.scrollEase = function() {
    this.onEnterFrame = function() {
        if (Math.abs(dy) == 0 && drag == false) {
            delete this.onEnterFrame;
        }
        r = (this._x-xD)/(bar._width-this._width);
        dy = Math.round((((top-(top-bottom)*r)-main._x)/speed)*friction);
        main._x += dy;
    };
};