# Scrollbar troubles

**URL:** https://forum.kirupa.com/t/scrollbar-troubles/206052
**Category:** Uncategorized
**Created:** [November 4, 2006, 5:10pm UTC](https://forum.kirupa.com/t/scrollbar-troubles/206052 "2006-11-04T17:10:34Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Haz567](https://avatars.discourse-cdn.com/v4/letter/h/ea5d25/32.png) [@Haz567](https://forum.kirupa.com/u/Haz567)
#### Post date: [November 4, 2006, 5:10pm UTC](https://forum.kirupa.com/t/scrollbar-troubles/206052/1 "2006-11-04T17:10:34Z")

</div>

For reference - (ignore the bad photoshopped labels as they were for another question)

![](http://i52.photobucket.com/albums/g17/Haz657/picture.jpg)

Okay i’m trying to get a customisable scroll-bar to work. Which in itself shouldn’t be hard but i’m finding rather illogical. The scrollbar is in the bottom left.

I have a movie clip with a group of buttons i want to scroll down, but they will not stop. When they reach the top point of the movie clip the scrolling will stop, but when i go to scroll down, it goes on forever.

How i have it set up is i have a layer with the movie clip, which is masked to hide the parts i don’t want to see. I have two seperate buttons on a layer, which respectively run up and down and move the movie clip appropriately. The scrollbar is supposed to move within these boundaries but it won’t correspond with the buttons when i use them. When i click on it to drag it doesn’t work, it just makes things disappear within the movie clip.

What i am using is this code on a seperate layer to run it -

scrolling = function () {  
var scrollHeight:Number = scrollTrack.\_height;  
var contentHeight:Number = contentMain.\_height;  
var scrollFaceHeight:Number = scrollFace.\_height;  
var maskHeight:Number = maskedView.\_height;  
var initPosition:Number = scrollFace.\_y=scrollTrack.\_y;  
var initContentPos:Number = contentMain.\_y;  
var finalContentPos:Number = maskHeight-contentHeight+initContentPos;  
var left:Number = scrollTrack.\_x;  
var top:Number = scrollTrack.\_y;  
var right:Number = scrollTrack.\_x;  
var bottom:Number = scrollTrack.\_height-scrollFaceHeight+scrollTrack.\_y;  
var dy:Number = 0;  
var speed:Number = 10;  
var moveVal:Number = (contentHeight-maskHeight)/(scrollHeight-scrollFaceHeight);

scrollFace.onPress = function() {  
var currPos:Number = this.\_y;  
startDrag(this, false, left, top, right, bottom);  
this.onMouseMove = function() {  
dy = Math.abs(initPosition-this.\_y);  
contentMain.\_y = Math.round(dy\*-1\*moveVal+initContentPos);  
};  
};  
scrollFace.onMouseUp = function() {  
stopDrag();  
delete this.onMouseMove;  
};  
btnUp.onPress = function() {  
this.onEnterFrame = function() {  
if (contentMain.\_y+speed\<maskedView.\_y) {  
if (scrollFace.\_y\<=top) {  
scrollFace.\_y = top;  
} else {  
scrollFace.\_y -= speed/moveVal;  
}  
contentMain.\_y += speed;  
} else {  
scrollFace.\_y = top;  
contentMain.\_y = maskedView.\_y;  
delete this.onEnterFrame;  
}  
};  
};  
btnUp.onDragOut = function() {  
delete this.onEnterFrame;  
};  
btnUp.onRollOut = function() {  
delete this.onEnterFrame;  
};  
btnDown.onPress = function() {  
this.onEnterFrame = function() {  
if (contentMain.\_y-speed\>finalContentPos) {  
if (scrollFace.\_y\>=bottom) {  
scrollFace.\_y = bottom;  
} else {  
scrollFace.\_y += speed/moveVal;  
}  
contentMain.\_y -= speed;  
} else {  
scrollFace.\_y = bottom;  
contentMain.\_y = finalContentPos;  
delete this.onEnterFrame;  
}  
};  
};  
btnDown.onRelease = function() {  
delete this.onEnterFrame;  
};  
btnDown.onDragOut = function() {  
delete this.onEnterFrame;  
};

if (contentHeight\<maskHeight) {  
scrollFace.\_visible = false;  
btnUp.enabled = false;  
btnDown.enabled = false;  
} else {  
scrollFace.\_visible = true;  
btnUp.enabled = true;  
btnDown.enabled = true;  
}  
};  
scrolling();

But it doesn’t seem to work. Any flash handy people know whats going on? Thanks.
