# Page scrollebar not working

**URL:** https://forum.kirupa.com/t/page-scrollebar-not-working/320129
**Category:** flash
**Created:** [March 15, 2011, 2:17am UTC](https://forum.kirupa.com/t/page-scrollebar-not-working/320129 "2011-03-15T02:17:52Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![WILWILWEL](https://avatars.discourse-cdn.com/v4/letter/w/a88e4f/32.png) [@WILWILWEL](https://forum.kirupa.com/u/WILWILWEL)
#### Post date: [March 15, 2011, 2:17am UTC](https://forum.kirupa.com/t/page-scrollebar-not-working/320129/1 "2011-03-15T02:17:52Z")

</div>

Hello there and thanks in advanced to trying to help.

I’m busy making a page scrollbar with the code below. All visable stuff is on stage. But when i render the movieclip the bar isnt working at all

- selecting the dragger doesnt seem to work (on click function doesnt work)
- cant drag the dragger down.
- thus no scrolling 😢

the fla is 9 mb so i didnt add it. the size is due to local pics whom will be replaced with dynamic content when the scrolling is fixed

> 

import flash.display.MovieClip;  
import flash.events.Event;  
import flash.events.MouseEvent;  
import flash.geom.Rectangle;  
import caurina.transitions.Tweener;  
var bounds:Rectangle;  
var startY:Number;  
var contentY:Number;

addEventListener(Event.[COLOR=red]AD[/COLOR][COLOR=red]DED\_TO\_STAGE[/COLOR], init); //change code below  
function init(e:Event):void {  
removeEventListener(Event.[COLOR=red]ADDED\_TO\_STAGE[/COLOR], init); //changed code below  
scrollHandle.addEventListener(MouseEvent.MOUSE\_DOWN, drag);  
scrollBar.addEventListener(MouseEvent.CLICK, tween);  
addEventListener(Event.ENTER\_FRAME, moveBox);  
startY = scrollHandle.y;  
contentY = scrollingContent.y;  
bounds = new Rectangle([COLOR=red]scrollHandle.x, scrollHandle.y, scrollBar.height - (scrollHandle.height + 2), 0[/COLOR]); //changed code below  
}

function tween(e:MouseEvent):void {  
var mousePos:Number = mouseY;  
if(mousePos \> (scrollBar.y + scrollBar.height) - (scrollHandle.height + 2)){  
mousePos = (scrollBar.y + scrollBar.height) - (scrollHandle.height + 2);  
}  
Tweener.addTween(scrollHandle, {y: mousePos, time: 1});  
}  
function drag(e:MouseEvent):void {  
scrollHandle.startDrag(false, bounds);  
scrollHandle.gotoAndStop(2);  
scrollHandle.removeEventListener(MouseEvent.MOUSE\_DOWN, drag);  
addEventListener(MouseEvent.MOUSE\_UP, stopdrag);  
}  
function stopdrag(e:MouseEvent):void {  
scrollHandle.stopDrag();  
scrollHandle.gotoAndStop(1);  
scrollHandle.addEventListener(MouseEvent.MOUSE\_DOWN, drag);  
removeEventListener(MouseEvent.MOUSE\_UP, stopdrag);  
}  
function moveBox(e:Event):void {  
scrollingContent.y = -((contentY - startY) + scrollHandle.y) \* ((scrollingContent.height - masker.height) / (scrollBar.height - scrollHandle.height));  
}
