Actionscript 2, Actionscript 2.0, Flash, Flash _, Tutorials, Web developer

MouseControl class – easy adding of mouse scroll wheel capability to Flash (AS2.0)


MouseControl class
for now just takes care of Mouse scroll wheel capability in Flash
MouseControl is Singleton class which lets you define movieclips and functions that should be invoked if user uses mouse scroll wheel over defined movie clip
it helps very much in situation when you need to define scrolling functionality in different classes of your Flash site or application

  • command addScroll(id, mc, function)
    MouseControl.getInstance().addScroll(“area1”, area1, Delegate.create(_root, moveFirst));
  • removeScroll(id)

example SWF :

source ZIP :

I just also want to suggest that this is not correctly written Singleton class. Singleton classes should throw arror on attemp of basic class creation like:

var mouseControl = new MouseControl() ;

but mine is doing nothing, it is expecting that you use it correctly and that when you want to use class always use internal class instance (basic of Singleton), getting it with standard

var mouseControl = MouseControl.getInstance()

or with commands

MouseControl.getInstance().addScroll(id, mc, func)

avoiding doing proper Singleton is basiclly of AS2 which is not so strong typed language …
In AS3 I recommend you do proper Singleton – nice guide you can find on Grant Skinners blog


14 thoughts on “MouseControl class – easy adding of mouse scroll wheel capability to Flash (AS2.0)

  1. LL says:

    Looks really interesting, can you please save a Flash 8 version since its AS2 – the file seems to be CS3. Thank you, it would be very much appreciated.

  2. Pingback: Actionscript Classes » MouseControl

  3. LL says:

    Thank you for the quick update! Looks really nice. I just wish the “mouseScroll(delta)” feature worked on Macs also.

    Thanks again for your quick response, really appreciated!

  4. I’ve tried to use the MouseControl class and it works very well, thanks for sharing.
    I’m very bad in programming, but I would ask if there’s an easy way to have the scroll detection initialized immediately (using the script as it is, I have the movieclip scrolling correctly, only after a first mouse click). Thanks very much

  5. first click is needed due to the focus
    at the page load flash does not have focus for mouse wheel event
    even if it have focus for text input it needs to be clicked

  6. Thank you for your immediate reply. I solved putting the code within a movieclip which should be clicked in order to visualize the “scrollable” section.

  7. pinero says:

    Hi there, very good piece of work, very useful code, I’m using it to make an interactive map like this:
    as you can see i have an bg_mc(background map), and im increasing or decreasing its width and height, my problem is that i want after the image is wider than 2000px scrolling to stop, and it worked, but i can’t take the “zoom out” effect out again, i came up with this code :

    var brzina:Number = 10;
    function moveFirst(num:Number):Void {

    if (bg_mc._width>2000) {
    bg_mc._width += -num*0;
    bg_mc._height += -num*0;
    } else {
    bg_mc._width += -num*brzina;
    bg_mc._height += -num*brzina;


    any help will be acpreciated …

  8. I have tried that macMouseWheel class and it does not work in AS2, FYI.
    Well at least not for me.

    Can you post a source for a AS2 example for those who are AS challenged like me? All I want is to be able to Zoom in and out within a size parameter like Stefano was saying. It just doesn’t recognize the mouse wheel. I am on OSX 10.4.11 BTW with a logitech optical mouse with a wheel using safari.

  9. Pingback: MouseControl AS2 class update - added Mac mouse wheel and scrolling area support « Cyberspace Nova

  10. qhrome27 says:


    I have implemented the scroll wheel in my Flash, and it works when testing, but it does not work in the new version of FireFox.

    It scrolls in Internet Explorer, but FireFox is a no-go.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s