Okay, I tried to adapt the script Kirupa posted for adding a scrollbar to a file I was using, with some success. When I add only the script for the vertical scrollbar, it works fine. However, when I adapt the script to horizontal scrolling (replace y’s with x’s, ._ymouse with ._xmouse, this._height with this._width, and so on) the vertical cursor makes the mask move to the bottom right of my movie clip and the horizontal cursor jumps off the scrollbar to the middle of my clip! What am I doing wrong? Feel free to make all the “noob” jokes you want, but please help! Dragger and bar are vertical, draggerX and barX are horizontal. Here’s my script (Kirupa’s modded script, thanks for the great site, bro!) :
fscommand(“allowscale”, “false”);
bar.useHandCursor = dragger.useHandCursor=false;
space = 20;
friction = 0.9;
speed = 4;
y = dragger._y;
top = main._y;
bottom = main._y+mask_mc._height-main._height-space;
dragger.onPress = function() {
drag = true;
this.startDrag(false, this._x, this._parent.y, this._x, this._parent.y+this._parent.bar._height-this._height);
dragger.scrollEase();
};
dragger.onMouseUp = function() {
this.stopDrag();
drag = false;
};
bar.onPress = function() {
drag = true;
if (this._parent._ymouse>this._y+this._height-this._parent.dragger._height) {
this._parent.dragger._y = this._parent._ymouse;
this._parent.dragger._y = this._y+this._height-this._parent.dragger._height;
} else {
this._parent.dragger._y = this._parent._ymouse;
}
dragger.scrollEase();
};
bar.onMouseUp = function() {
drag = false;
};
moveDragger = function (d) {
if ((dragger._y>=y+bar._height-dragger._height && d == 1) || (dragger._y<=y && d == -1)) {
clearInterval(myInterval);
} else {
dragger._y += d;
dragger.scrollEase();
updateAfterEvent();
}
};
up_btn.onPress = function() {
myInterval = setInterval(moveDragger, 18, -1);
};
down_btn.onPress = function() {
myInterval = setInterval(moveDragger, 18, 1);
};
up_btn.onMouseUp = down_btn.onMouseUp=function () {
clearInterval(myInterval);
};
MovieClip.prototype.scrollEase = function() {
this.onEnterFrame = function() {
if (Math.abs(dy) == 0 && drag == false) {
delete this.onEnterFrame;
}
r = (this._y-y)/(bar._height-this._height);
dy = Math.round((((top-(top-bottom)*r)-main._y)/speed)*friction);
main._y += dy;
};
};
fscommand(“allowscale”, “false”);
barX.useHandCursor = draggerX.useHandCursor=false;
space = 20;
friction = 0.9;
speed = 4;
x = draggerX._x;
left = main._x;
right = main._x+mask_mc._width-main._width-space;
draggerX.onPress = function() {
drag = true;
this.startDrag(false, this._y, this._parent.x, this._y, this._parent.x+this._parent.barX._height-this._width );
draggerX.scrollEase();
};
draggerX.onMouseUp = function() {
this.stopDrag();
drag = false;
};
barX.onPress = function() {
drag = true;
if (this._parent._xmouse>this._x+this._width-this._parent.draggerX._width ) {
this._parent.draggerX._x = this._parent._xmouse;
this._parent.draggerX._x = this._x+this._width-this._parent.draggerX._width;
} else {
this._parent.draggerX._x = this._parent._xmouse;
}
draggerX.scrollEase();
};
barX.onMouseUp = function() {
drag = false;
};
moveDragger = function (d) {
if ((draggerX._x>=x+bar._width-draggerX._width && d == 1) || (draggerX._x<=x && d == -1)) {
clearInterval(myInterval);
} else {
draggerX._x += d;
draggerX.scrollEase();
updateAfterEvent();
}
};
L_btn.onPress = function() {
myInterval = setInterval(moveDragger, 18, -1);
};
R_btn.onPress = function() {
myInterval = setInterval(moveDragger, 18, 1);
};
L_btn.onMouseUp = R_btn.onMouseUp=function () {
clearInterval(myInterval);
};
MovieClip.prototype.scrollEase = function() {
this.onEnterFrame = function() {
if (Math.abs(dx) == 0 && drag == false) {
delete this.onEnterFrame;
}
r = (this._x-x)/(barX._width-this._width);
dx = Math.round((((left-(left-right)*r)-main._x)/speed)*friction);
main._x += dx;
};
};