Claudio scroll bar

So this is the actionscript for the scrollbar done by Claudio.



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;
	};
};


I have a slight problem when two scrollbars share the same time frame. I can get two scrollbars to work when the timeline moves to a different frame but then the scrollbars reset position - which I don’t want them to do. I.e If I have content in say scrollbar one which contains buttons that bring up more content that uses a second scrollbar there are conflict issues.

First I tried changing the names of the instances but I found the same problems. I’m guessing that the scrollbars are sharing the variable names that are causing the scrollbar to conflict. Having tried changing the variables to try and get the scrollbars to work independently I end up not being able to get it working at all (even on its own) The problem is I don’t really understand all the code.

Can someone help me and change the above code to a new one that will work in conjunction with the original. (I can change the instances of the movieclips as well if need be.) Thanks very much.