SWFObject add-on: MouseWheel on Mac OS

I've had the mouse wheel working in flash on OS X for a while, and after seeing the SWFAddress add-on for deconcept's SWFObject embedding system, I thought I'd add mousewheel functionality to SWFObject, rather than using my own "frankenstein" embedding system.

It's straight forward to implement. Download SWFMacMouseWheel here.



Within ActionScript, you'll barely notice any difference. Only that instead of using Mouse.addListener(), you'll refer to my class instead.

Example code:

Actionscript:
  1. import com.pixelbreaker.ui.MouseWheel;
  2.  
  3. class Example
  4. {
  5.  
  6. function Example(){
  7. MouseWheel.addListener( this );
  8. }
  9.  
  10. public function onMouseWheel( delta:Number ):Void
  11. {
  12. // do something with the delta value
  13. }
  14. }

All the javascript is included in the zip, with an example html file.

You simply have to add one line of code to the javascript:

JavaScript:
  1. var so = new SWFObject('test.swf', 'website', '100%', '100%', '8', '#FFFFFF');
  2.  
  3. so.useExpressInstall('js/expressinstall.swf');
  4.  
  5. so.addParam('menu', 'false');
  6. so.addParam('scale', 'noscale');
  7. so.addParam('salign', 'lt');
  8.  
  9. // CHANGE BELOW
  10. if( so.write('flashcontent') )
  11. {
  12. var macmousewheel = new SWFMacMouseWheel( so );
  13. }

85 Comments so far

  1. Geoff / November 9th, 2006 1:06 am

    Awesome, this is actually very useful... we have clients all the time that want mouse wheel support on macs.

  2. pixelbreaker / November 9th, 2006 1:30 am

    Hi Geoff, glad it's of use. I've also got a little class that allows flash movies to be 100% of the browser, but not go below a certain size, I'll make that work along side SWFObject in the next week, I'll let you know when it's done.

  3. Zokdok / November 9th, 2006 8:37 am

    Thanks for bringing mouse wheel support publicly to the mac :).
    I'll start integrating it when I switched to swfObject, which brings me to your own reply, I need that 'not go below a certain size' functionality. I have it already, but by switching over to SWFObject, I have to reimplement it.

    I'll be checking your blog a lot from now on, and I hope you have it sooner then next week, as I'm currently in the process of adapting the code... which would same me a some time and trouble.
    (Or maybe you could send me the beta code, in which I can help test and bug hunt.)

    thanks!

  4. [...] Extending Flash support in browser is the new black these days. Pixelbreaker adds a very welcome addition by extending support for the mouse wheel in Flash to the Macs with is own MouseWheel extension. Finally mouse wheel support is no longer Windows only! [...]

  5. [...] ya puedes utilizar la ruedecita del ratn desde flash en mac aqu esta el “truco” [...]

  6. pixelbreaker / November 9th, 2006 12:18 pm

    hi zokdok, I'll get it done asap, just i'm finishing my current employment tomorrow, so big party tonight, gonna be a bit tricky to get anything done before sunday...

  7. danielyuen.hk Blog : links for 2006-11-09 / November 9th, 2006 3:26 pm

    [...] pixelbreaker SWFObject add-on: MouseWheel on Mac OS (tags: flash actionscript swfobject mousewheel osx) [...]

  8. Freddy / November 11th, 2006 10:34 pm

    Hi Pixelbreaker, thanks a lot for the script!!!, Is there any way to use it without swfObject? (some layouts just make it hard to use swfObject)

    Also, this will work only with Flash 8 and up?

    thanks again!.

  9. pixelbreaker / November 11th, 2006 11:38 pm

    It should work fine with Flash 7, you just have to be using ActionScript 2.0. The version available above will only work with SWFObject. I've not had any issues using SWFObject with different layouts.

  10. jeanphilippe / November 12th, 2006 10:02 am

    Hi,
    It seems it doesn't run on Safari 2.0.4, flash Player 9

  11. pixelbreaker / November 12th, 2006 4:22 pm

    I'm running it on Safari 2.0.4 here, and it's fine.

  12. Chester McLaughlin » Fundamental Flash Features / November 13th, 2006 6:32 pm

    [...] Mac ScrollWheel Support [...]

  13. Dave Glanz / November 14th, 2006 6:47 pm

    With Safari, I get this message when opening the sample:

    str:
    onMouseWheel: [type Function]
    $version: MAC 9,0,16,0
    mouse_txt: _level0.mouse_txt
    test_txt: _level0.test_txt

    Using Firefox 2.0, I'm getting the "You need to upgrade your Flash Player!" message.

  14. Dave Glanz / November 14th, 2006 6:48 pm

    With Safari, I get this message when opening the sample:

    str:
    onMouseWheel: [type Function]
    $version: MAC 9,0,16,0
    mouse_txt: _level0.mouse_txt
    test_txt: _level0.test_txt

    Also, when using Firefox 2.0, I'm getting the "You need to upgrade your Flash Player!" message.

  15. pixelbreaker / November 14th, 2006 7:17 pm

    Dave, the flash detection is working in firefox 2.0 on Windows and OS X for me, maybe you should direct questions for that to deconcept (who made the detection scripts).

    The message you see in safari is correct, that's what my test movie shows... once you scroll the mouse wheel, you should see another textfield to the right, echoing some numbers, depending on which direction you're scrolling your wheel.

    Hope you get it sorted...

  16. Dave Glanz / November 15th, 2006 2:44 pm

    Pixelbreaker, thanks for the response...

    Still not seeing any changes when scrolling though, (using Safari). Has anyone else had trouble with this? I'd love to see it working!

  17. [...] A couple of weeks ago pixelbreaker released a kick-ass add-on to SWFObject called SWFMacMouseWheel which enables the mousewheel support in Flash for OSX.  I was a little bummed on their example code though… so I’ve created a little example of some scrolling textFields. It uses a simple hitTest to see if mouse is over the textField and then increments the vPosition accordingly. example [...]

  18. Hugo Ahlberg / November 23rd, 2006 11:02 am

    This is great. Thank you very much.. I posted it on Digg.com
    http://digg.com/programming/Mouse_wheel_support_in_Flash_finally_on_Mac_OS_X

  19. Dai / November 27th, 2006 3:22 pm

    Great work!
    It works on safari 2.0.4 and OSX 10.4.8.

  20. Kev Sutherland / December 4th, 2006 11:06 am

    Hi, I too am getting the same response as Dave, I see the textfields on the top left but when I use the mouse scroller I don't see anything changing, this happens when I use firefox or Safari. I'm running FP 9 in both cases.

    Both the example SWF and my own attempts both fail to show output from the scrollwheel.

    Any ideas?

  21. Pedro Jonen / December 5th, 2006 12:27 pm

    Hi... I also had the same Problem lke Dave and Kev, using Saf 2.0.4 or Firefox 2.0...
    LOCAL... it has to be online (on the Server) to work!!!

    Thx, it's great!

  22. pixelbreaker / December 6th, 2006 2:50 pm

    Pedro, you probably have to change your flash player security settings and allow "c:\" if you're on PC or "Macintosh HD" if you're on mac.

  23. Zokdok / December 8th, 2006 3:51 pm

    You might want to change the main() to init() or something when you're used to work with mtasc (like me).

  24. mecklen / January 24th, 2007 3:56 pm

    While working with Flex 2 on a AS3 project a textfield suddenly scrolled by wheel - and this on the MAC!!! standalone debug player. Also MouseEvent.MOUSE_WHEEL is broadcasted. Although the mac mouse wheel support is still missing in the flash plugin itself (9.28), it seems to be in the pipe now!

  25. [...] Extending Flash support in browser is the new black these days. Pixelbreaker adds a very welcome addition by extending support for the mouse wheel in Flash to the Macs with is own MouseWheel extension. Finally mouse wheel support is no longer Windows only! [...]

  26. [...] » Läs mer på pixelbreaker.com. [...]

  27. [...] Part of eepmon version 3 allows the user to use their mouse wheel to scroll through content. Works great in Windows but no go on a MAC.  So I’ve done a google search and stumbled upon pixelbreaker’s site where he has resolved the mouse wheel conflict. [...]

  28. eepmon / February 16th, 2007 4:30 am

    Hello,

    I am creating my new version of my site and the mouse wheel is working perfectly on Firefox. It also works in Safari but it seems to be dispatching mouse wheel event twice causing the navigation to skip every 2nd item. Could this be a browser issue? Has anyone come across this?

    Thank you

  29. [...] Mac OSX Support [...]

  30. linkbizkits » Blog Archive » SWFMacMouseWheel / February 22nd, 2007 2:44 pm

    [...] Get all the info here [...]

  31. Joel / March 8th, 2007 6:37 pm

    hi,

    i'm trying to add the mousewheel to my movies. first of all i want to get something like your test.swf made by me, but i'm having some troubles.

    i'm just making a new flash movie, named test.swf and overwrite yours. on the movie i'm making on the first frame
    i'm adding all the example code you detail on the top of this site like this:

    import com.pixelbreaker.ui.MouseWheel;
    class Example
    {
    function Example(){
    MouseWheel.addListener( this );
    }
    public function onMouseWheel( delta:Number ):Void
    {
    myTextField = delta;
    }
    }

    first problem. Flash debugger is telling me that i can only define classes in AS external scripts.
    .. i'm not very used to work with classes, so i try only
    leaving the first line (import com.pixelbreaker.ui.MouseWheel;) in the flash movie and placing the rest of the code at the end of the mouswheel.as file ... i also define into the publication configuration menu of the flash movie the folders where all the .as files are contained..
    it doesn't work too.

    please, explain me better how could i use this very usefull code or upload the test.fla.

    thanks you

  32. Joel / March 8th, 2007 6:38 pm

    sorry, there's some more.
    the firefox debugger keeps telling me these everytime the mousewheel is moved:

    document[this.so.getAttribute("id")].externalMouseEvent is not a function
    [Break on this error] document[ this.so.getAttribute('id') ].externalMouseEvent( delta );

    thanks again.

  33. DYOBLOG / March 15th, 2007 11:34 am

    クロスプラットフォーム Flashスクロールクラス&JS Beta...

    ジミーな研究。 ■Flash8のスクロール関係コンポーネントがどうも使いづらい。......

  34. guzelsozler / March 15th, 2007 10:34 pm

    thenk you

  35. Shane McCartney / March 16th, 2007 6:59 am

    I have desccovered a bug with this code with the undocumented scrollTarget parameter onMouseWheel event. Basically this param tells you what movieclip the mouse is currently over. The following code fixes this if this could be updated in the source it would be a good idea.

    The solution is a bit of a hack but it works

    private public static function externalMouseEvent(delta:Number):Void
    {
    var st:MovieClip = _root.createEmptyMovieClip("st", _root.getNextHighestDepth());
    st.startDrag();
    //
    st.func = macBroadcaster.broadcastMessage;
    st.scope = macBroadcaster
    st.args = ["onMouseWheel", delta];
    //
    st.onEnterFrame = function() {
    //
    this._x = _root._xmouse;
    this._y = _root._ymouse;
    //
    if (this._droptarget != "" && this._droptarget!= undefined) {
    //
    this.args.push(eval(this._droptarget));
    this.func.apply(this.scope, this.args);
    //
    delete this.onEnterFrame;
    this.removeMovieClip();
    }
    };
    }

  36. Shane McCartney / March 16th, 2007 7:03 am

    Sorry typo in the above change that first line from

    private static function externalMouseEvent(delta:Number):Void
    {
    var st:MovieClip = _root.createEmptyMovieClip("st", _root.getNextHighestDepth());
    st.startDrag();
    //
    st.func = macBroadcaster.broadcastMessage;
    st.scope = macBroadcaster
    st.args = ["onMouseWheel", delta];
    //
    st.onEnterFrame = function() {
    //
    this._x = _root._xmouse;
    this._y = _root._ymouse;
    //
    if (this._droptarget != "" && this._droptarget!= undefined) {
    //
    this.args.push(eval(this._droptarget));
    this.func.apply(this.scope, this.args);
    //
    delete this.onEnterFrame;
    this.removeMovieClip();
    }
    };
    }

  37. [...] Now getting Scroll Wheel to work on Mac is a little trickier as Flash doesn’t have native support for this but there is a way to get this to work in Flash 8. The Javascript and Actionscript provided code from PixelBreaker as a SWFObject add-on allows you to do this. It’s pretty good but has one shortcoming and that is that it only provides the delta parameter and not scrollTarget, I have an Actionscript fix for this and it’s a bit of a hack but hey it works, I hope u find this useful. [...]

  38. islami site islami sohbet / March 17th, 2007 10:44 pm

    I have still problems with the code, anyone can solve it? thanks

  39. hi_gui / March 21st, 2007 6:18 pm

    Great work man, you saved my ass!
    I'm not such an experet, but i did it to work in a couple of hours.
    Thanx again
    hi_gui

  40. pixelbreaker / April 9th, 2007 4:57 pm

    Shane, good that you got scrolltarget working, I never use it, and creating _root movieclips is too hacked for my liking. By all means, publish your own version of the code.

    cheers

  41. [...] SWFMacMouseWheel [...]

  42. [...] UPDATE As the Flash Player for Macs doesn't have support for Mousewheel events, I have updated the source code with a mac version which uses a javascript workaround. You'll also need to download the SWFMacMouseWheel class from pixelbreaker. I have tested it on Mac OS X Safari and Firefox, works fine. To install the class, copy the "com" folder and paste it into your Actionscript 2.0 class folder. Typical paths are Windows: Hard DiskDocuments and SettingsuserLocal SettingsApplication DataAdobeFlash CS3languageConfigurationClasses Macintosh: Hard Disk/Users/user/Library/Application Support/Adobe/Flash CS3/language/Configuration/Classes [...]

  43. Sohbet / May 16th, 2007 10:07 am

    nice work

  44. Sohbet / May 16th, 2007 10:08 am

    Thank you

  45. sohbet / May 17th, 2007 2:10 am

    thank you very much webmaster for nice site. i am reading all write. thanks again. works is very nice

  46. [...] This extra also showcases the use of the SWFMacMouseWheel javascript, by PixelBreaker. By using this javascript, MAC users can also scroll through the playlist with their mousewheel. [...]

  47. Keven / June 8th, 2007 8:22 pm

    I'll admit, I'm no actionscript pro so if anyone has used this fancy mousewheel stuff with a custom scrollbar such as this:
    http://www.kirupa.com/developer/flash8/scrollbar.htm
    can you please let me know.
    Thanks

  48. izlesene / June 9th, 2007 6:02 pm

    I want to use vista.. but my os don't support them!

    youtube
    mirc
    radyo
    mirc
    sohbet
    sohbet

  49. Oliver Bujdoso / June 10th, 2007 4:35 pm

    Works great in Safari, but on Windows with IE, the scroll wheel doesn't work until you click on something (activeX). The swfobject.js doesn't work for the scrollwheel.

  50. sohbet / June 14th, 2007 1:44 pm

    thanks for all

  51. youtube / June 15th, 2007 10:40 am

    thanks :)

  52. sorguc / June 16th, 2007 10:46 am

    thx for all

  53. bilim / June 16th, 2007 10:59 am

    Wow, this is a great release. I won't have that much use for the resizable columns, but the new feed navigation is really great for me!

  54. Apteka internetowa / July 5th, 2007 12:18 pm

    It's very good article. Great site with very good look and perfect information... Thanks

  55. ChaT SohbeT / July 6th, 2007 11:08 am

    Works great in Safari, but on Windows with IE, the scroll wheel doesn't work until you click on something (activeX) The swfobject.js doesn't work for the scrollwheel...

  56. Sohbet / July 6th, 2007 10:24 pm

    Wow, this is a great release. I won't have that much use for the resizable columns

  57. Sohbet odalari / July 7th, 2007 7:07 am

    It's very good article. Great site with very good look and perfect information.

    Thnks...

  58. Arkadas / July 8th, 2007 5:42 am

    Wow, this is a great release. I won't have that much use for the resizable columns, but the new feed navigation is really great for me!!!

    Murat Boz

  59. Resim / July 8th, 2007 7:20 am

    the firefox debugger keeps telling me these everytime the mousewheel is moved:
    document[this.so.getAttribute("id")].externalMouseEvent is not a function
    [Break on this error] document[ this.so.getAttribute('id') ].externalMouseEvent( delta );
    thanks again...

    Grup Hepsi

  60. Mirc / July 8th, 2007 10:26 am

    I'll be checking your blog a lot from now on, and I hope you have it sooner then next week, as I'm currently in the process of adapting the code... which would same me a some time and trouble.
    (Or maybe you could send me the beta code, in which I can help test and bug hunt.)Sohpet

  61. video izle / July 8th, 2007 11:06 pm

    thank you

  62. indir / July 9th, 2007 10:54 am

    the firefox debugger keeps telling me these everytime the mousewheel is moved:
    document[this.so.getAttribute("id")].externalMouseEvent is not a function
    [Break on this error] document[ this.so.getAttribute('id') ].externalMouseEvent( delta );
    thanks again...

  63. kyle / July 9th, 2007 2:03 pm

    Thank you very much

  64. Arkadas / July 10th, 2007 8:20 am

    I'll admit, I'm no actionscript pro so if anyone has used this fancy mousewheel stuff with a custom scrollbar such as this:.

  65. mp3indir / July 10th, 2007 2:20 pm

    mp3indir
    zirve

    thanks

  66. gazeteler / July 10th, 2007 8:48 pm

    Hi, I'm Turkish science communicator.I like very very much Nature Podcast.

    Congratulations!

  67. Hasse G / July 13th, 2007 8:51 am

    Hi. I found your site a while back when I was looking for existing solutions for OS X mouse wheel support, but found none that would be easily plugged to Flex/AS3 apps, so I implemented one myself. You can find it here:

    http://hasseg.org/blog/?p=3

  68. Paylasim / July 14th, 2007 6:13 am

    Hi. I also had the same Problem lke Dave and Kev, using Saf 2.0.4 or Firefox 2.0.
    Local. it has to be online (on the Server) to work

  69. Saglik / July 14th, 2007 9:59 am

    Does that mean, using your example class, I would state: mouseListener = new Example(); Mouse.addListener(mouseListener);? If not, then what?
    Thanks.

  70. sohbet odalari / July 15th, 2007 7:10 am

    Hi.
    [...] A couple of weeks ago pixelbreaker released a kick-ass add-on to SWFObject called SWFMacMouseWheel which enables the mousewheel support in Flash for OSX. I was a little bummed on their example code though… so I’ve created a little example of some scrolling textFields. It uses a simple hitTest to see if mouse is over the textField and then increments the vPosition accordingly. example [...]

  71. islami sohbet / July 15th, 2007 7:36 am

    Hello, I too am getting the same response as Dave, I see the textfields on the top left but when I use the mouse scroller I don't see anything changing, this happens when I use firefox or Safari. I'm running FP 9 in both cases. dini sohbet

  72. adobe / July 15th, 2007 7:57 am

    thanx

  73. forum problem bank / July 17th, 2007 12:31 am

    thanks for all knowledge

  74. [...] SWFMacMouseWheel [...]

  75. kale kapi / July 25th, 2007 4:58 am

    thanks good [...] SWFMacMouseWheel [...]

  76. kale kapi / July 27th, 2007 1:04 am

    Shane, good that you got scrolltarget working, I never use it, and creating _root movieclips is too hacked for my liking. B

  77. izms » Blog Archive » links for 2007-08-04 / August 4th, 2007 11:21 pm

    [...] pixelbreaker : SWFObject add-on: MouseWheel on Mac OS I’ve had the mouse wheel working in flash on OS X for a while, and after seeing the SWFAddress add-on for deconcept’s SWFObject embedding system, I thought I’d add mousewheel functionality to SWFObject, rather than using my own “frankenstein” embedding sy (tags: actionscript javascript swfobject MouseWheel mac flash) [...]

  78. [...] en ai profité pour utiliser le javascript swfmacmousewheel.js qui permettrait à la mousewhell mac de fonctionner sur flash (impossible de vérifier je suis sur [...]

  79. Mouse Wheel problems | zedia flash blog / September 20th, 2007 12:05 am

    [...] tried to use the fix to make the mouse wheel work in Flash when you use Mac OS X that can be found here. But that didn’t do it. My last option was to use the new technique from the makers of [...]

  80. Paul Mayne / October 19th, 2007 7:43 am

    Top 6 Flash Development Tools...

    1) Fuse Kit For movieClip tweening I’ve been using the Zigo Tween engine until I saw Moses Gunesch at the Flash Forward conference in Austin showing off this amazing set of classes. Fuse is built upon the Zigo engine and......

  81. [...] Gabriel Bucknail created almost a year ago a SWFObject add-on to bring MouseWheel support to the Mac OS X Flash Player. Seems to be still up to date: Solution [...]

  82. Humming Via Kitchen / February 2nd, 2008 8:28 am

    AS3でSWFMacMouseWheelを作ってみたよ。...

    SWFMacMouseWheel がAS2にしか対応してないらしくて、
    勢いでAS3に対応したヤツを作ってみたよ。
    使い方はある程度真似てみたんだけれども、
    AS2を知らないので何とも。
    AS側の使い...

  83. Not-so-Minimal Scrollbar at Bumpslide / April 7th, 2008 10:17 pm

    [...] (via FTween). There is a textpanel there, too. Sorry, no buttons on the scrollbar. You are using swfmacmousewheel, [...]

  84. credit card consolidation uk / April 30th, 2008 2:28 pm

    software gioco poker...

    Still best credit card debt help telecharger poker superstars...

  85. FICC inc. at 1222north / May 7th, 2008 3:54 pm

    [...] UPDATE: I was curious, so I did a quick search and discovered that someone figured out how to get the Mouse Wheel to work in Flash on a Mac through SWFObject. BooYah. [...]