# Scroller Tutorial from AS2 to AS3

**URL:** <https://forum.kirupa.com/t/scroller-tutorial-from-as2-to-as3/319828>\
**Category:** flash\
**Created:** [March 5, 2011, 8:47pm UTC](https://forum.kirupa.com/t/scroller-tutorial-from-as2-to-as3/319828 "2011-03-05T20:47:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![BritJ](https://avatars.discourse-cdn.com/v4/letter/b/8e8cbc/32.png) [@BritJ](https://forum.kirupa.com/u/BritJ)\
**Post date:** [March 5, 2011, 8:47pm UTC](https://forum.kirupa.com/t/scroller-tutorial-from-as2-to-as3/319828/1 "2011-03-05T20:47:52Z")

</div>

I’ve searched for almost a whole week to get this thing converted, and I’m pretty sure I’m an idiot who has had the answers in front of her the whole time.

I found a great tutorial for a scrollbar that was exactly what I was looking for. I wanted something that didn’t have up or down buttons, had a thin line for the track, and a circular dragger. However, it was written in AS2. I’ve tried to convert it myself, but I’m a complete beginner, and I know nothing about AS3 code, or AS2 for that matter. So, I’ve managed to get the scroller icon to move, but it moves all over the screen & doesn’t stay put. It also doesn’t scroll. Help me!! (Thanks in advance… :geek: )

[FONT=Courier New]var scrollUpper:Number = 31.5;  
var scrollLower:Number = 381.5;[/FONT]  
[FONT=Courier New][/FONT]  
[FONT=Courier New]var textLower:Number = 40;  
var textUpper:Number = -40;[/FONT]  
[FONT=Courier New][/FONT]  
[FONT=Courier New]var scrollRange:Number = scrollLower - scrollUpper;  
var textRange:Number = textLower - textUpper;[/FONT]  
[FONT=Courier New][/FONT]  
[FONT=Courier New]function scroll() {  
var moved:Number = scroller\_mc.y - scrollUpper;  
var pctMoved:Number = moved/scrollRange;  
var textMove:Number = pctMoved\*textRange;  
text\_mc.y = textLower - textMove;  
}[/FONT]  
[FONT=Courier New][/FONT]  
[FONT=Courier New]scroller\_mc.buttonmode = false;  
scroller\_mc.addEventListener(MouseEvent.MOUSE\_DOWN, dragScroller);  
scroller\_mc.addEventListener(MouseEvent.MOUSE\_UP, dropScroller);[/FONT]  
[FONT=Courier New][/FONT]  
[FONT=Courier New]function dragScroller(evt:MouseEvent):void {  
scroller\_mc.startDrag();  
}[/FONT]  
[FONT=Courier New][/FONT]  
[FONT=Courier New]function dropScroller(evt:MouseEvent):void {  
scroller\_mc.stopDrag();  
}[/FONT]
