# Scrollbar

**URL:** https://forum.kirupa.com/t/scrollbar/49873
**Category:** Uncategorized
**Created:** [April 27, 2004, 2:41pm UTC](https://forum.kirupa.com/t/scrollbar/49873 "2004-04-27T14:41:42Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![jakke](https://avatars.discourse-cdn.com/v4/letter/j/f04885/32.png) [@jakke](https://forum.kirupa.com/u/jakke)
#### Post date: [April 27, 2004, 2:41pm UTC](https://forum.kirupa.com/t/scrollbar/49873/1 "2004-04-27T14:41:42Z")

</div>

Hi guys,  
I want to make a scrollbar and i have already this code (it’s stolen from Flash to the core) but this code is horizontal how can I make this scroll vertical?

Here’s the code:

// set up content\_mc info  
contentRight = \_root.content\_mc.\_x;  
contentLeft = 715-\_root.content\_mc.\_width;

// set up gutter info  
gutterLeft = \_root.scrollbarGutter\_mc.\_x+1;  
gutterRight = ((\_root.scrollbarGutter\_mc.\_x+\_root.scrollbarGutter\_mc.\_width)-this.\_width)-1;

// don’t use the hand icon  
this.useHandCursor = false;

// handle press event  
this.onPress = function() {  
this.startDrag(false, gutterLeft, this.\_y, gutterRight, this.\_y);  
dragging = true;  
this.onMouseMove = function() {  
updateAfterEvent();  
};  
};

// handle release event  
this.onRelease = this.onReleaseOutside = function() {  
this.onMouseMove = undefined;  
this.stopDrag();  
dragging = false;  
xSpeed = (newxpos-oldxpos)\*RATIO;  
};

// set initial variables  
FRICTION = .9;  
RATIO = .5;  
dragging = false;

// handle onEnterFrame event  
this.onEnterFrame = function() {  
if (!dragging) {  
oldxpos = this.\_x;  
newxpos = oldxpos+xSpeed;  
xSpeed _= FRICTION;  
if (newxpos\>gutterRight || newxpos\<gutterLeft) {  
xSpeed = -FRICTION;  
newxpos = oldxpos;  
}  
this.\_x = newxpos;  
// always move content\_mc whether dragging or not  
var percent = (this.\_x-gutterLeft)/(gutterRight-gutterLeft);  
this.\_parent.content\_mc.\_x = percent(contentLeft-contentRight)+contentRight;  
} else {  
oldxpos = newxpos;  
newxpos = this.\_x;  
// always move content\_mc whether dragging or not  
var percent = (this.\_x-gutterLeft)/(gutterRight-gutterLeft);  
this.\_parent.content\_mc.\_x = percent_(contentLeft-contentRight)+contentRight;  
}  
};
