Hello there!
I’ve made the kirupa simple scrollbar horizontal. This works just perfect but it is not smooth. My question to you is - how to make it smooth? I’ve been searching in different forums all night but I just can’t find an answer.
I’ve got 4 MC’s with the instance names content, mask, scroll_area and scroller.
My AS looks like this:
onClipEvent (load) {
_root.content_width = content._width;
_root.scroller_area_width = scroll_area._width;
scroller._width = _root.scroller_area_width/(content._width/scroll_area._width);
_root.scroller_width = scroller._width;
_root.maxXMove = _root.scroller_area_width - _root.scroller_width;
function updateScrollbar () {
content._x = - scroller._x * ((content._width - mask._width) / _root.maxXMove);
}
}
onClipEvent (mouseDown) {
if (scroller.hitTest(_root._xmouse,_root._ymouse)) {
scroller.startDrag(0,_root.maxXMove,0,0);
scrolling = true;
}
if (right.hitTest(_root._xmouse,_root._ymouse)){
right.gotoAndStop(2);
direction = -1;
scrolling = true;
_root.right_controller.gotoAndPlay(2);
}
if (left.hitTest(_root._xmouse,_root._ymouse)){
left.gotoAndStop(2);
direction = 1;
scrolling = true;
_root.left_controller.gotoAndPlay(2);
}
}
onClipEvent (mouseUp) {
stopDrag();
scrolling = false;
right.gotoAndStop(1);
left.gotoAndStop(1);
_parent.left_controller.gotoAndStop(1);
_parent.right_controller.gotoAndStop(1);
}
onClipEvent(enterFrame){
if (scrolling){
updateScrollbar();
}
}
I have tried myself to make it smooth by adding this piece of text but it just don’t work!:
var funkyVar = -this._parent.scroller._x*(((this._width-this._parent.scroller._width)/(this._parent.scroll_area._width-this._parent.scroller._width))-1) this.X = (funkyVar-this._x)*.2;
this._x += this.X;
if(Math.abs(funkyVar-this._x)<1 && !dragging){
delete this.onEnterFrame
}
Someone help me please!!
Best
- Oscar