# Mouse scroll zoom tip

**URL:** https://forum.kirupa.com/t/mouse-scroll-zoom-tip/271373
**Category:** flash
**Created:** [September 22, 2008, 12:42pm UTC](https://forum.kirupa.com/t/mouse-scroll-zoom-tip/271373 "2008-09-22T12:42:43Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Guzak](https://avatars.discourse-cdn.com/v4/letter/g/858c86/32.png) [@Guzak](https://forum.kirupa.com/u/Guzak)
#### Post date: [September 22, 2008, 12:42pm UTC](https://forum.kirupa.com/t/mouse-scroll-zoom-tip/271373/1 "2008-09-22T12:42:43Z")

</div>

Hey, this took me a LONG time to sort out so i thought i’d post it online so others find it eaier.  
This allows you to zoom on a mc with the mouse scroll while keeping the mc centered by the cursor.

```auto
addEventListener(MouseEvent.MOUSE_WHEEL, Zoom);
         function Zoom(e:MouseEvent):void
        {
            var mod:Number = 10;
            map_drag.scaleX += e.delta / mod;
            map_drag.scaleY += e.delta / mod;
            map_drag.x = ((2 * mouseX) - (2 * (e.localX * map_drag.scaleX))) / 2;
            map_drag.y = ((2 * mouseY) - (2 * (e.localY * map_drag.scaleY))) / 2;
        }

```

Hope this helps 😏
