# Horizontal Scrollbar w/ MC issue

**URL:** <https://forum.kirupa.com/t/horizontal-scrollbar-w-mc-issue/206882>\
**Category:** flash\
**Created:** [November 12, 2006, 7:34pm UTC](https://forum.kirupa.com/t/horizontal-scrollbar-w-mc-issue/206882 "2006-11-12T19:34:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jezzhaigh](https://avatars.discourse-cdn.com/v4/letter/j/dfb087/32.png) [@jezzhaigh](https://forum.kirupa.com/u/jezzhaigh)\
**Post date:** [November 12, 2006, 7:34pm UTC](https://forum.kirupa.com/t/horizontal-scrollbar-w-mc-issue/206882/1 "2006-11-12T19:34:57Z")

</div>

Hullo,

Having some issues with this AS that i’ve taken from an example tutorial. It originally used a vertical scroller, but I’ve changed it to horizontal. However, having issues with the ‘dragger’ itself - not dragging properly or keeping to the ‘bar’, etc. I wonder if someone could take a look for me?

I’ve changed the reference from height to width, and swapped the y’s for x’s, but it aint doing what it should do…

Thanks, Here it is:

fscommand(“allowscale”, “false”);  
bar.useHandCursor = dragger.useHandCursor=false;  
space = 20;  
friction = 0.9;  
speed = 4;  
x = dragger.\_x;  
top = main.\_x;  
bottom = main.\_x+mask\_mc.\_width-main.\_width-space;  
dragger.onPress = function() {  
drag = true;  
this.startDrag(false, this.\_y, this.\_parent.x, this.\_x, this.\_parent.x+this.\_parent.bar.\_width-this.\_width);  
dragger.scrollEase();  
};  
// Above is where the problem lies …  
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\>=x+bar.\_width-dragger.\_width && d == 1) || (dragger.\_x\<=x && d == -1)) {  
clearInterval(myInterval);  
} else {  
dragger.\_x += d;  
dragger.scrollEase();  
updateAfterEvent();  
}  
};  
up\_btn.onPress = function() {  
myInterval = setInterval(moveDragger, 4, -1);  
};  
down\_btn.onPress = function() {  
myInterval = setInterval(moveDragger, 4, 1);  
};  
up\_btn.onMouseUp = down\_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)/(bar.\_width-this.\_width);  
dx = Math.round((((top-(top-bottom)\*r)-main.\_x)/speed)\*friction);  
main.\_x += dx;  
};  
};
