# Scroll Wheel confusion

**URL:** <https://forum.kirupa.com/t/scroll-wheel-confusion/287744>\
**Category:** flash\
**Created:** [May 5, 2009, 8:18pm UTC](https://forum.kirupa.com/t/scroll-wheel-confusion/287744 "2009-05-05T20:18:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![rusbugus](https://avatars.discourse-cdn.com/v4/letter/r/8797f3/32.png) [@rusbugus](https://forum.kirupa.com/u/rusbugus)\
**Post date:** [May 5, 2009, 8:18pm UTC](https://forum.kirupa.com/t/scroll-wheel-confusion/287744/1 "2009-05-05T20:18:49Z")

</div>

Hi,

I got my scroll wheel to finally start working after lots of research for my scroll bar that i created, but now I’m confused about something. When i scroll up, the bar goes down, and when I scroll down, the bar goes up. I have 2 scroll bars on a page that I’ve gotten to work independently, and I fixed one to scroll down when you scroll down and up when you scroll up. I tried the same code for the other one, but it doesn’t work. Does anybody know what I need to do?

code:  
\<–Code for the big scroll bar that works correctly–\>  
stage.addEventListener(MouseEvent.MOUSE\_WHEEL, handleMouseWheel);  
function handleMouseWheel(event:MouseEvent): void {  
if ((-(event.delta) \> 0 && sb.thumb.y \< 684.4) && (mouseX \>= 408.6) || (-(event.delta) \< 0 && sb.thumb.y \> 0) && (mouseX \>= 408.6)){  
sb.thumb.y = sb.thumb.y + (-(event.delta) \* 3);  
var sp:Number = sb.thumb.y / yMax;  
Tweener.addTween(ss, {y:(-sp\*(ss.height-masker.height)), time:.5});  
event.updateAfterEvent();  
if (sb.thumb.y \>= 684.4)  
sb.thumb.y = 693;  
if (sb.thumb.y \< 9)  
sb.thumb.y = sb.thumb.y - sb.thumb.y;  
}  
}

\<–code that works except the scrolling is messed up–\>  
stage.addEventListener(MouseEvent.MOUSE\_WHEEL, handleMouseWheel2);  
function handleMouseWheel2(event:MouseEvent): void {  
if ((event.delta \> 0 && sb2.thumb2.y \< 250) && (mouseX \< 408.6) || (event.delta \< 0 && sb2.thumb2.y \> 0) && (mouseX \< 408.6)){  
sb2.thumb2.y = sb2.thumb2.y + (event.delta \* 2);  
var sp:Number = sb2.thumb2.y / yMax2;  
Tweener.addTween(group, {y:(-sp\*(group.height-maskee.height)), time:.5});  
event.updateAfterEvent();  
if (sb2.thumb2.y \>= 234)  
sb2.thumb2.y = 250;  
if (sb2.thumb2.y \< 9)  
sb2.thumb2.y = sb2.thumb2.y - sb2.thumb2.y;  
}  
}
