# Simple Scroll Bar Question

**URL:** https://forum.kirupa.com/t/simple-scroll-bar-question/211672
**Category:** flash
**Created:** [January 4, 2007, 2:53am UTC](https://forum.kirupa.com/t/simple-scroll-bar-question/211672 "2007-01-04T02:53:33Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Amy\_Peterson](https://avatars.discourse-cdn.com/v4/letter/a/3be4f8/32.png) [@Amy\_Peterson](https://forum.kirupa.com/u/Amy_Peterson)
#### Post date: [January 4, 2007, 2:53am UTC](https://forum.kirupa.com/t/simple-scroll-bar-question/211672/1 "2007-01-04T02:53:33Z")

</div>

hello again,

Ok im trying to use this scrollbar i got from [kirupa.com](http://kirupa.com)…its the custom one…

now everything works on it except wen i click the up button…wen i click the up button it jus goes str8 back to the top instead of scrolling…i downloaded the whole Scrollbar and wen i compared to code to the Custom Scrollbar Tutorial, there were different at the btnUp.onPress = function() { part…

here is the code on the scrollbar i downloaded

scrolling = function () {  
var scrollHeight:Number = scrollbg.\_height;  
var contentHeight:Number = contentMain.\_height;  
var draggerHeight:Number = dragger.\_height;  
var maskHeight:Number = maskedView.\_height;  
//  
var initPosition:Number = dragger.\_y=scrollbg.\_y; var initContentPos:Number = contentMain.\_y;  
var finalContentPos:Number = maskHeight-contentHeight+initContentPos;  
//  
var left:Number = scrollbg.\_x;  
var top:Number = scrollbg.\_y;  
var right:Number = scrollbg.\_x;  
var bottom:Number = scrollbg.\_height-draggerHeight+scrollbg.\_y;  
//  
var dy:Number = 0;  
var speed:Number = 10;  
var moveVal:Number = (contentHeight-maskHeight)/(scrollHeight-draggerHeight);  
//  
dragger.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);  
};  
};  
dragger.onMouseUp = function() {  
stopDrag();  
delete this.onMouseMove;  
};  
btnUp.onPress = function() {  
this.onEnterFrame = function() {  
if (contentMain.\_y + speed \< maskedView.\_y) {  
trace(dragger.\_y + " " + top);  
if (dragger.\_y \<= top) {  
dragger.\_y = top;  
contentMain.\_y += speed;  
} else {  
contentMain.\_y += speed;  
dragger.\_y -= speed / moveVal;  
}  
} else {  
dragger.\_y = top;  
contentMain.\_y = maskedView.\_y;  
delete this.onEnterFrame;  
}  
};  
};  
btnUp.onDragOut = function() {  
delete this.onEnterFrame;  
};  
btnUp.onMouseOut = function() {  
delete this.onEnterFrame;  
};  
btnDown.onPress = function() {  
this.onEnterFrame = function() {  
if (contentMain.\_y - speed \>finalContentPos) {  
if (dragger.\_y\>=bottom) {  
contentMain.\_y -= speed;  
dragger.\_y = bottom;  
} else {  
contentMain.\_y -= speed;  
dragger.\_y += speed/moveVal;  
}  
} else {  
dragger.\_y = bottom;  
contentMain.\_y = finalContentPos;  
delete this.onEnterFrame;  
}  
};  
};  
btnDown.onRelease = function() {  
delete this.onEnterFrame;  
};  
btnDown.onDragOut = function() {  
delete this.onEnterFrame;  
};  
};  
scrolling();

Now…here is the code on the tutorial

```
 		 		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&lt;maskedView._y) {if (scrollFace._y&lt;=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&gt;finalContentPos) {if (scrollFace._y&gt;=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&lt;maskHeight) {scrollFace._visible = false;btnUp.enabled = false;btnDown.enabled = false;} else {scrollFace._visible = true;btnUp.enabled = true;btnDown.enabled = true;}};scrolling(); 	   

```

i would like to go with the first code i pasted…but ive tried both and the first one wen i click up goes all the way up without stopping…the second one jus doesnt let me scroll up at all lol…so if someone can help me with the first code that i pasted…

Basic Problem = When i click the scollup button, it goes all the way to the top without stopping…

Thank you,

Amy
