# MouseWheel Speed and Mathematics

**URL:** https://forum.kirupa.com/t/mousewheel-speed-and-mathematics/223407
**Category:** flash
**Created:** [April 22, 2007, 11:33am UTC](https://forum.kirupa.com/t/mousewheel-speed-and-mathematics/223407 "2007-04-22T11:33:34Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![RubenFlash](https://avatars.discourse-cdn.com/v4/letter/r/839c29/32.png) [@RubenFlash](https://forum.kirupa.com/u/RubenFlash)
#### Post date: [April 22, 2007, 11:33am UTC](https://forum.kirupa.com/t/mousewheel-speed-and-mathematics/223407/1 "2007-04-22T11:33:34Z")

</div>

Hello. 🍺

Please, have a look at the following code:

```php

//---------------
listenmen = new Object();
var bottom_b:Number = scrollBG._height - scrollBtn._height + scrollBG._y;

listenmen.onMouseWheel = function(delta) {
    if (delta > 1) delta = 5;
    if (delta < -1) delta = -5;
    delta = -delta;
    if (delta > 0) {
        scrollBtn._y = Math.min(bottom_b, scrollBtn._y + delta);
          }
      if (delta < 0) {
        scrollBtn._y = Math.max(scrollBG._y, scrollBtn._y + delta);
      }
    setContentTarget();
}

Mouse.addListener(listenmen);
//--------------

```

This code enables the use of the mousewheel to scroll through a movieclip. What I wanted was to make it more dinamic. As you can see, the delta value determines the speed of the scrolling. I want that this speed be calculated accordding to the height of the movieclip that its being scrolled. I already tried a linear approach by using a simple equation like delta = scrolled\_mc.\_height/50 but isnt really working. So, basically, I want that, if a movieclip is big, the scroll is faster and reverse. So, could somebody help me?

Cheers! 🍺
