# Customized scroll bar

**URL:** <https://forum.kirupa.com/t/customized-scroll-bar/262872>\
**Category:** Uncategorized\
**Created:** [June 10, 2008, 6:36pm UTC](https://forum.kirupa.com/t/customized-scroll-bar/262872 "2008-06-10T18:36:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mirka](https://avatars.discourse-cdn.com/v4/letter/m/97f17d/32.png) [@mirka](https://forum.kirupa.com/u/mirka)\
**Post date:** [June 10, 2008, 6:36pm UTC](https://forum.kirupa.com/t/customized-scroll-bar/262872/1 "2008-06-10T18:36:01Z")

</div>

[FONT=Lucida Sans Unicode]Hello peeps, any ideas on what went wrong? [/FONT]  
[FONT=Lucida Sans Unicode][/FONT]  
[FONT=Lucida Sans Unicode]I have been attempting to create a simple scroll-bar following the tutorials from [kirupa.com](http://kirupa.com). After I have exported the flash file, it came up with errors saying this: [/FONT]  
[FONT=Lucida Sans Unicode][/FONT]  
[FONT=Lucida Sans Unicode]Statement must appear within on/onClipEvent handler Statement (source) scrolling = function ()}[/FONT]  
[FONT=Lucida Sans Unicode][/FONT]  
Statement must appear within on/onClipEvent handler (source) scrolling();

thnx

---

<div class="post-metadata">

**Author:** ![mirka](https://avatars.discourse-cdn.com/v4/letter/m/97f17d/32.png) [@mirka](https://forum.kirupa.com/u/mirka)\
**Post date:** [June 10, 2008, 6:37pm UTC](https://forum.kirupa.com/t/customized-scroll-bar/262872/2 "2008-06-10T18:37:39Z")

</div>

what is easier: scroll bar using a masking tool or dynamic text. is there any difference?

---

<div class="post-metadata">

**Author:** ![snickelfritz](https://avatars.discourse-cdn.com/v4/letter/s/7ea924/32.png) [@snickelfritz](https://forum.kirupa.com/u/snickelfritz)\
**Post date:** [June 10, 2008, 8:38pm UTC](https://forum.kirupa.com/t/customized-scroll-bar/262872/3 "2008-06-10T20:38:10Z")

</div>

Here’s an AS3 text scrollbar, with TweenMax easing, and link to external text file.  
I have no clue how to do it AS2.

```auto
import gs.TweenMax;
import fl.motion.easing.*;

function loadText():void {
	var txtLoader:URLLoader = new URLLoader();
	txtLoader.addEventListener(Event.COMPLETE, onLoaded);
	txtLoader.load(new URLRequest("pharetra.txt"));
	removeEventListener(Event.COMPLETE, onLoaded);

	function onLoaded(e:Event):void {
		content.text = txtLoader.data;
	}
}

loadText();

var yOffset:Number;
var yMin:Number = 0;
var yMax:Number = sb.track.height - sb.thumb.height;

sb.thumb.addEventListener(MouseEvent.MOUSE_DOWN, thumbDown);
stage.addEventListener(MouseEvent.MOUSE_UP, thumbUp);

function thumbDown(e:MouseEvent):void {
	stage.addEventListener(MouseEvent.MOUSE_MOVE, thumbMove);
	yOffset = mouseY - sb.thumb.y;
}

function thumbUp(e:MouseEvent):void {
	stage.removeEventListener(MouseEvent.MOUSE_MOVE, thumbMove);
}

function thumbMove(e:MouseEvent):void {
	sb.thumb.y = mouseY - yOffset;
	if (sb.thumb.y <= yMin) {
		sb.thumb.y = yMin;
	}
	if (sb.thumb.y >= yMax) {
		sb.thumb.y = yMax;
	}
	var sp:Number = sb.thumb.y / yMax;
	TweenMax.to(content, 1, {y:(-sp*(content.height - masker.height)), ease:Back.easeOut});
	e.updateAfterEvent();
}

```
