AS3.0 MouseWheel on Mac OS X

I've finally found the time to port my SWFObject add-on SWFMacMouseWheel (catchy I know) to ActionScript 3.0 and SWFObject 2.0

There's now two examples in the zip, one for use with SWFObject 1.5, and a totally re-written version for use with SWFObject 2.0 (formerly SWFFix)

All you have to do in your main application class (or document class) is

Actionscript:
  1. import com.pixelbreaker.ui.osx.MacMouseWheel;
  2.  
  3. MacMouseWheel.setup( stage );

You can then add listeners to TextFields, Sprites etc etc as you normally would any other MouseEvent.

Example JavaScript to be used with the dynamic embed method

JavaScript:
  1. var vars = {};
  2. var params = { scale:'noScale', salign:'lt', menu:'false' };
  3. var attributes = { id:'testObject', name:'testObject' }; // give an id to the flash object
  4.  
  5. swfobject.embedSWF("test_as3.swf", "flashContent", "100%", "100%", "9.0.0", "js/expressInstall.swf", vars, params, attributes );
  6. swfmacmousewheel.registerObject(attributes.id);

I have updated the SWFObject 2.0 version to be more compact, and it also falls inline with the code style of SWFObject2.0. see swfmacmousewheel_src.js for the uncompressed version, deploy swfmacmousewheel2.js on your site.

Download source and demo here or view the demo online

131 Comments so far

  1. Jason / February 7th, 2008 8:07 pm

    Thanks gabe! Very nicely done!

  2. Man / February 8th, 2008 12:24 pm

    God bless you, your children, the children of your children for this wheel thing :)

  3. Chris / February 12th, 2008 7:18 am

    Thanks! You're my new best friend! :)

  4. shaun / February 25th, 2008 1:17 pm

    Yaaaaayyyyyy!!!! Thanks so much. A real lifesaver! And nicely implemented too. I like how you've stuck to the style of SWFObject 2.0

  5. Ben / February 25th, 2008 11:34 pm

    Thanks! You've made me not look so lame!

  6. Jamie McDaniel / March 1st, 2008 3:35 am

    Thanks so much for this solution to the mouseWheel on Macs. Now if I can just get the mouseWheel to work on Firefox 2 in Windows.

    Just a note for those wondering how to get it to work in a Flex mxml application, use MacMouseWheel.setup(Application.application.stage). I had to put this line of code in the applicationComplete event handler rather than the initialize or creationComplete event handlers.

  7. Jamie McDaniel / March 1st, 2008 3:42 am

    In my post above, I should have provided the detail that setting wmode=opaque breaks Flash’s MouseWheel in Firefox 2 on Windows. A javascript solution similar to your MacMouseWheel would probably be a work around until either Mozilla or Adobe fixes the problem.

  8. MyridoM / March 2nd, 2008 8:26 am

    You need to check out Chumby.com
    With your mad flash skills, you'd have some fun with it.

    MyridoM

  9. cap10subtext / March 3rd, 2008 12:37 am

    This works wonders. Thanks so much!

  10. Frederik Heyninck / March 3rd, 2008 3:28 pm

    Firefox with firebug gives a problem in the console:

    swfmacmousewheel has no properties
    http://blog.pixelbreaker.com/downloads/swfmacmousewheelas3demo/index_as3.html
    Line 15

    Any solution?

  11. gabriel / March 3rd, 2008 7:25 pm

    is that on windows? if so, i should clean that up, at present, if the OS is not a mac, it returns a null object as swfmacmousewheel.

  12. davi garms / March 4th, 2008 8:45 pm

    very good, thank you very much! now i'm stucked in another problem... :( anybody knows how to make the mouse wheel to work in windows firefox with transparent wmode? in mac it works fine with this code, even with transparent set, but in windows.... it simply doesn't work in this mode!! thanks for the attention.

  13. gabriel / March 5th, 2008 12:35 am

    davi: I'll have a look into this...

  14. gotjosh / March 10th, 2008 5:17 pm

    Hi!

    Many thanks for your tight js hack to compensate for adobe's painful laziness (or blatant prejudice) (or whatever other undogly reason that this isn't natively supported)

    I am working on an extension of the MacMouseWheel object to also send MiddleMouse Button Events.

    I have a prototype working in parallel to Gabriel's swfMacMouseWheel... here is a zip file:
    http://www.gotblogua.gotjosh.net/media/MacMouseMiddleButton.zip

    I learned a bit from here:
    http://unixpapa.com/js/testmouse.html

    Gabriel, i think this could be tighter... and i wonder if you or any of your visitors may have the fire to review the code and maybe post a better integrated version...

    please feel free to contact me with comments and or questions...

    NOTE: totally unsupported ALPHA version... i am looking for people to help me make this work better, not people to ask me how they can use it to solve their problems... it will probably make more problems than it solves at this point ;-)

  15. muhabbet / March 20th, 2008 1:11 pm

    This works wonders. Thanks so much!

  16. thibaud / March 22nd, 2008 11:48 am

    Thanks a lot for the script Gabriel.
    one thing:
    I just installed safari 3.1 on windows, I can't believe it also has the mousewheel amputated for flash content. You might want to add a check for the few ppl using it as well.

  17. Shinobu / March 25th, 2008 11:21 pm

    Yep I just tried it on Safari for windows.. Doesn't work :/ (Safari Ver 3.1)

  18. Dan / March 27th, 2008 7:26 pm

    This class was so simple to implement and solves such a huge problem. Thanks very much

  19. Pete / March 31st, 2008 2:05 pm

    Gabriel, you're distributing this with svn files included starting at /ui level. Thanks for sharing your code.

  20. ketch / April 2nd, 2008 7:07 pm

    I don't understand, i have safari 3.1 on windows, and i can't run the demo online ?

  21. Tenchi / April 5th, 2008 9:37 pm

    hey thanks for this wonderful script , very easy to implement works great

    please let us know if can fix the wmode problem.
    a fix for safari on windows would aslo be great :D

    keep up the good work !

  22. Railk / April 8th, 2008 12:27 am

    A big thanks for this really useful script that really works great.

    For those who want it, i made a small fix for the script to work on safari for windows that you can find here (everything is explain on the readme.txt inside the rar)

    http://railkill.free.fr/safari/safariFixed.rar

    you can view a working sample here:
    http://railkill.free.fr/monolog/

    Not sure it's the best solution, but it works while waiting for Gabriel to update his script ^^.

    Thx again for you script !

  23. Wheener / April 30th, 2008 7:16 pm

    You code just made in onto a MOMA minro site

    http://media.moma.org/subsites/2008/olafureliasson/#/intro/

  24. Wheener / April 30th, 2008 7:17 pm

    Your code just made in onto a MOMA minro site

    http://media.moma.org/subsites/2008/olafureliasson/#/intro/

  25. simurai / May 7th, 2008 5:03 pm

    I noticed something funny with the fullscreen mode.. on Mac Safari it works in normal mode but not in fullscreen mode and on Windows Safari it's the opposite.. it doesn't work in normal mode, but it DOES work in fullscreen mode. Pretty strange.. ;-) Note: I'm using the new JS but still the old AS 2.0 script.

  26. nl-x / May 8th, 2008 10:14 am

    This sounds good.
    However I primarily had given up on Mac Scrollwheeling and was searching for a solution on another problem that could be solved by this if ported for Windows...

    The thing is: to give a Flash App focus from the browser (to be able to start typing in a Flash Text Field directly after visiting the site), you need to give the Flash App focus from JavaScript myObject.focus(), and in Flash give the focus to the component needing to get focus by doing for example creationComplete="myComponent.setFocus();" (Flex).
    However, in FireFox, the javascript myObject.focus() will only work if the Flash object is loaded using wmode="opaque". And that again breaks scroll wheel functionality in Windows FireFox.

    Question:
    - Are there any known side-effects from this script by PixelBreaker?
    - Is there any Windows Port (to be build by anyone) ?

    Kind regards,
    nl-x

  27. aşk şiirleri / June 13th, 2008 10:54 am
  28. matthew / June 20th, 2008 2:48 am

    Great work! I think you can simplify the API a bit though: ExternalInterface exposes the SWF's id via its objectID property. Since you're already requiring ExternalInterface, why not just have the SWF register itself? If you call swfmacmousewheel.registerObject(ExternalInterface.objectID) from your MacMouseWheel._setup method, you can completely eliminate the need for any additional javascript in your HTML.

  29. supadupa / June 20th, 2008 10:02 am

    Is this possible with AS2?

  30. ryan / June 30th, 2008 1:11 pm

    thanks, very much apreciated. just one thing... can you delete your .svn data out of the source...

  31. andré felipe menezes / July 11th, 2008 11:36 pm

    I am like the 2nd that commented: "God bless you, your children, the children of your children for this wheel thing :)"

    DIE HTML DIEEEE :))

  32. lula / July 25th, 2008 1:40 pm

    Hello!
    I'm trying to run the test_as3.fla directly from my Flash CS3 and the mouseWheel doesn't work.
    Is it posible to do it this way or you need the hlml with the JavaScript inside to work?
    Sorry for this basic question.
    Thanks in advanced.

  33. bobby / August 18th, 2008 8:44 pm

    Hey Pixelbreaker,

    I like the fact that the macmousewheel allows me to utilize the scrollwheel in FireFox on a PC, and Safari on a Mac.

    However, I have run into a couple issues with it:

    1- On Firefox on a PC, if you use the parameter
    so.addParam('wmode', 'transparent');
    the scrollwheel does not work. It works fine on IE on a PC though.

    2- Although the macmousewheel makes the scroll wheel active on Safari for Mac, it completely disables the scroll wheel for the entire page that the Flash is embedded in. The scroll wheel works only in the Flash and nowhere else on the page.

    Do you have any solutions to this?

    With these issues unresolved, my best fix currently is to stop using macmousewheel so that I get the other functionality I am looking for.

  34. daan / August 19th, 2008 8:56 pm

    I bow down... this is a very nice piece of work, thanx

  35. busby seo challenge / August 26th, 2008 4:32 pm

    great post for mac

    import com.pixelbreaker.ui.osx.MacMouseWheel;

    MacMouseWheel.setup( stage );

  36. dimpiax / August 27th, 2008 2:20 pm

    Great thank U :)

  37. Giles / September 3rd, 2008 4:11 pm

    Bobby is right in (2) above - if your Flash embedding fails (e.g. the person does not have Flash installed) the Mousewheel is then broken for the alternative content!

    What would be ideal is if the event handlers could only be attached on the first call of registerObject() so that mouse wheeling worked as normal for HTML if no call to the class was made.

    G

  38. morris / September 9th, 2008 4:53 am

    Gabriel, Great work, thanks for putting it out there. My question is actually relating to your old version of the MouseWheel for AS2.

    I had the AS3 version working, but due to some other elements of the site I'm working on, I am forced to use AS2. The problem occurs while loading SWFs that use MouseWheel into a container using LoadMovie... on the second load (whichever clip I choose to load second using the menu) the browser crashes once you try to scroll using the wheel.

    This happens in firefox and safari (latest versions of both browsers and OSX) and no matter what order I load the clips in. Here's an example...

    http://www.designbus.com/debug

    I'm hoping at some point you may have solved the issue in your own usage of the AS2 version.

    I can only think that it has something to do with multiple loads of the class overloading the plugin? Or maybe a pile up of listeners. I don't know. I've tried clearing the listener manually on each load, and tried looking for a way to clear the import prior to a new load, all to no avail.

    Thanks for any info you, or anyone else here, may have.

  39. Romu / September 10th, 2008 5:57 pm

    Just brilliant, two lines added in my code and everything is working perfectly.

    Great work, I love when it is quick and easy :)

  40. matthias / September 11th, 2008 12:09 pm

    hello !

    first of all - great work (thanks !)
    if i test your online demo on
    firefox 3.01 (win xp) i get the following error: 'swfmacmousewheel is null'

    and on ie 6.0.2 (win xp): 'swfmacmousewheel is null or no object'
    (when i reload the error is gone...)

    flash player version is 9

    any suggestions ?

    thanks and stay well,
    matthias

  41. Michael Bailey / September 13th, 2008 3:39 pm

    I totally love this! Thank you for doing the work and sharing it with others.

    Do you think that you could come up with a quick SWFObject2.1 version? I'd like to use createSWF and removeSWF with this.

    Thanks!

  42. Michael Bailey / September 13th, 2008 3:41 pm

    Oh HEY! Nevermind it already does - turns out it was my flawed coding (/ar instead of var) doh.

    Thanks again - you are blessed!

  43. noponies / September 25th, 2008 9:56 am

    Thanks for this excellent contribution to the Flash community.

    Super easy to implement!

  44. yikulju / September 25th, 2008 11:50 am

    great work, there's one things I'd like to mention, I've also run the example on IE6 (XP) and the delta values are fairly different.

    IE values are often -+3 or -+6 but on Mac with you fix the values are quite nice, they're from -+1 to ...
    which is good but not consistent.

    regards,
    Viktor

  45. Jloa / October 3rd, 2008 10:27 am

    DOESN'T WORK IN SAFARI 3.0.3 (win32)

  46. andré felipe menezes / October 7th, 2008 8:18 am

    Hi, AWESOME script, I've been using for a while already. THANKS

    BUT I need for a new project to work with both browser and "in Flash" scroll wheel -- so I need to toogle it ON and OFF - is that possible??
    the project preview - http://www.anzuclub.com/preview/

    When the javascript is loaded in the .html the browser scrollwhell don't work -- and when I remove it, i does. (also tried removing the setup call in .as but no difference)
    (tested in safari 3.1.2 - mac osx 10.5.5)

    THANKS

  47. tam / October 14th, 2008 6:58 pm

    Juste a BIG THANKS DUDE
    all of my website is about a big scroll (yes like html style...)
    i first made it in as2 when i saw that the wheel mouse doesn't work on mac !!!!!!
    then i just spent 2 days to do it in as3 when i was just a shit in as2 ...but it's work !!!!
    THANKS A LOT

  48. Mike / October 14th, 2008 9:34 pm

    I love the class, but it seems to crash my browser every now and then. Anyone else have this issue? Using FF3 on mac, loading swf with class into a container swf.

  49. Cooking / October 19th, 2008 7:33 am

    Thank you very much for the work. Excellent contribution to the Flash community.

  50. sonicoliver / October 20th, 2008 8:08 am

    this is really slick, thanks!

    I like this comment: "With these issues unresolved, my best fix currently is to stop using macmousewheel so that I get the other functionality I am looking for."

    OMG, some people expect blood from us! :) "I'll be sure to try and meet your KPI this quarter bro..."

  51. Coert / October 21st, 2008 8:25 am

    I can't get it to work. I'm using SWFObject2.1 instead of 2.0 (and SWFAddress 2.1) are there known compatibility issues? I'm a newby at this, so I probably made a mistake somewhere, but you never know...

  52. Coert / October 21st, 2008 9:25 am

    Please ignore my previous comment, I made a mistake in the path to the javaScript. Happy to report it works with SWFObject2.1

  53. gorman2001 / October 22nd, 2008 1:30 am

    what the hell is that script ?!?!

    it's not working at all. i get errors each time i scroll in safari 3 and firefox 3 on mac.

    "obj is null" on line 41.

  54. Yu-Chung Chen / October 22nd, 2008 8:37 pm

    Hi!

    Thanks a bunch for the script!
    Works fine for me in the following cases:
    Windows XP IE 7.0.5730.13
    Windows XP Firefox 3.0.3
    Windows XP Opera 9.60
    OSX Safari 3.1.2 (5525.20.1)
    OSX Firefox 3.0

    Not on OSX Opera 9.60 though. Too bad because that's our main browser at home.

  55. Yu-Chung Chen / October 22nd, 2008 8:40 pm

    P.s. I'm using SWFaddress with SWFobject 1.5 because 2.1 doesn't seem to work with the former.

  56. izlekop / October 27th, 2008 11:28 pm

    Seems as if the hour ring isn’t right on windows xp …
    the current time is 2pm (1400) but the ring is bearly 1/4 around.

  57. melfar / October 31st, 2008 9:15 pm

    Hey guys! I might not be getting this right, but..
    Turning on this mousewheel hook captures mouse wheel events on the whole page. A small fix can make a check on the event target and filter only events above the Flash instances that were set up. Here it is:

    diff swfmacmousewheel_src.js swfmacmousewheel_src.js.orig
    12c12
    var swfmacmousewheel = function()
    39,42d38

    Works with Safari and Firefox on the mac. And I've just noticed Opera generates mouse wheel deltas upside down. :)

  58. melfar / October 31st, 2008 9:18 pm

    Strip_tags thing in Wordpress cut all my pretty diff lines. Anyhow, you should add this into the beginning of the deltaDispatcher function:

    for(var i=0; i

  59. melfar / October 31st, 2008 9:19 pm

    This is getting ridiculous :) I'll try one last time:

    for(var i=0; i < regObjArr.length; i++ )
    {
    if(event.target.id != regObjArr[i]) return;
    }

  60. Joseph / November 1st, 2008 12:35 am

    Hi there.

    I'm using the plugin, and keep having the same event fire twice. Has anyone else had this problem?

  61. Loris / November 5th, 2008 6:23 pm

    HI, I've got a problem. If the js, the html and swf are in the same folder there's no problem but if the html and the swf are in different folders your script doesn't work. ;(

    In my case:
    swfobject.embedSWF("http://engine.controlweb.me/flash/3041.versionadv.com/template.kreativo/3041/layout.swf", "flashcontent", "1000", "700", "9.0.0", "", flashvars, params, attributes);

    The html is http://3041.versionadv.com/

    Can you help me?

  62. AceOfThumbs / November 14th, 2008 2:21 am

    gabriel, thank you for swfmacmousewheel. This solves a serious oversight by Adobe.

    melfar, thank you for your fix posted above to allow Flash scrolling and normal HTML scrolling. It works great!

    For those asking about the Javascript errors in Windows similar to 'swfmacmousewheel is null', you can do a simple test to avoid the error. Use this:

    if (swfmacmousewheel) {
    swfmacmousewheel.registerObject(attributes.id);
    }

    instead of this:
    swfmacmousewheel.registerObject(attributes.id);

  63. evden eve nakliyat / November 29th, 2008 4:05 pm

    usefull great work

  64. ian ferger / November 30th, 2008 6:55 pm

    i wasnt able to get this to work with safari on windows so i cobbled this straightforward example from various different sources on the net:

    CODE:
    1. //goes in your head tag:
    2.             function handle(delta) {
    3.                 swfobject.getObjectById(swf's id
    4. ').flashScroll(delta);
    5.             }
    6.            
    7.             function wheel(event){
    8.            
    9.                 var delta = 0;
    10.                 if (!event) event = window.event;
    11.                 if (event.wheelDelta) {
    12.                     delta = event.wheelDelta/120;
    13.                     if (window.opera) delta = -delta;
    14.                 } else if (event.detail) {
    15.                     delta = -event.detail/3;
    16.                 }
    17.                 if ( delta != 0 )    handle(delta);
    18.                                  
    19.             }
    20.            
    21.            
    22.             //alert("window.addEventListener: "+window.addEventListener);
    23.             if (window.addEventListener){
    24.            
    25.            
    26.                 window.addEventListener('DOMMouseScroll',wheel, false);
    27.                 window.onmousewheel = document.onmousewheel = wheel;
    28.             }
    29.  
    30.  
    31. //the as3:
    32.  
    33. package {
    34.    
    35.     import flash.external.ExternalInterface;
    36.     import flash.events.*;
    37.     import flash.display.InteractiveObject;
    38.    
    39.     public class MouseWheelReceiver {
    40.        
    41.         private var _target;
    42.         public var successful:Boolean;
    43.         private var currentScroll:Number;
    44.         private var currentItem;
    45.         private var clonedEvent;
    46.        
    47.        
    48.         public function MouseWheelReceiver( __target=null  ){
    49.             _target= __target;
    50.             successful = ExternalInterface.available;
    51.            
    52.             if( successful ){
    53.                 ExternalInterface.addCallback("flashScroll", setScroll );
    54.                 target.stage.addEventListener( MouseEvent.MOUSE_MOVE , getItemUnderCursor );
    55.             }
    56.            
    57.         }//fn
    58.  
    59.         private function getItemUnderCursor( evt ) {
    60.            
    61.             var thisItem= evt.target;
    62.            
    63.             if( thisItem !== currentItem ){
    64.                 currentItem= InteractiveObject(  thisItem );
    65.                 clonedEvent = MouseEvent( evt );
    66.             }
    67.        
    68.         }//fn
    69.        
    70.         private function setScroll( delta:Number ):void{
    71.            
    72.             var wheelEvent:MouseEvent = new MouseEvent(
    73.                     MouseEvent.MOUSE_WHEEL,
    74.                     true,
    75.                     false,
    76.                     clonedEvent.localX,
    77.                     clonedEvent.localY,
    78.                     clonedEvent.relatedObject,
    79.                     clonedEvent.ctrlKey,
    80.                     clonedEvent.altKey,
    81.                     clonedEvent.shiftKey,
    82.                     clonedEvent.buttonDown,
    83.                     int( delta )
    84.                 );
    85.             currentItem.dispatchEvent( wheelEvent );
    86.            
    87.             if( currentItem.hasOwnProperty( 'scrollV' ) ){
    88.                 currentItem.scrollV +=  -delta;
    89.                
    90.             }
    91.         }//fn
    92.        
    93.         public function get target() {      return _target;      }//fn
    94.  
    95.     }//cls
    96. }//pkg

  65. Busby SEO Test / December 1st, 2008 11:31 am

    great thanks you

  66. Michael Vestergaard / December 12th, 2008 2:27 pm

    Thanks so much for sharing this. It works perfectly for me :-)

  67. Jloa / December 14th, 2008 3:31 am

    Still doesn't work in Safari 3.0.3 under win32

  68. ergimantas / December 16th, 2008 8:34 pm

    Does not work on Win Vista Safari 3.2.1

  69. nobu / December 21st, 2008 2:26 pm

    Hello.
    I'm working on a couple of projects in Flash, and I also release these projects at Spark project. My projects are inspired from your library.

    http://www.libspark.org/wiki/SWFWheel/en
    http://www.libspark.org/wiki/SWFSize/en

    If you do not mind, don't you participate in development together?
    If you may have participating in Spark Project, could you send USER NAME and PASSWORD to follow address? Regardless please be committer!!

    beinteractive.org@gmail.com

    I am waiting for your communication.
    Thank you.

    Takanobu Izukawa

  70. Adam / December 23rd, 2008 1:39 pm

    I'm trying to use this mousewheel functionality scrubbing a video using the FLVPlayback component.
    In the onBlockMouseWheel function I just added

    flvPlayback.playheadTime += e.delta;

    "flvPlayback" is the name of my video component.

    The playhead is moving and the video is scrubbing, but it looks as if the video has got the hiccups...

    Has anyone got experience in using the mousewheel functionality scrubbing a video?

    Thank you
    /Adam

  71. Karim Beyrouti / January 16th, 2009 1:58 pm

    Thanks!! this is great... however, i am sure you know, but - it does not seem to work with the latest version of SWFObject. Wondering if you are working on this?

    Thanks again

    Karim

  72. hs / January 25th, 2009 11:58 am

    If someone receives errors I'd recommend to wrap the code inside the _externalMouseEvent function as follows:

    if ( _clonedEvent != null && _currItem != null )
    {
    ...
    }

    If you have a blank background in your swf those variables may be null.

  73. kev / January 28th, 2009 4:15 am

    Dead set easiest method to implement - nice work!

    A gotcha I came across recently with using swfmacmousewheel with swfaddress is you must load the scripts in a specific order or one or the other may not function:

    Also, when working in Flex, I found that it's safer to do a project clean whenever you modify the html wrapper otherwise you may drive yourself slightly nuts.

    And finally a question for you all - I have a TextArea within a Canvas within a ViewStack. The ViewStack doesn't scroll with the mousewheel if the cursor is over the Canvas (I've set vericalScrollPolicy=off on both Canvas & TextArea).

    If I set mouseChildren=false on the Canvas, the ViewStack scrolls fine. But this disables the ability for people to select the text in the TextArea which I'd like to retain.

    Any suggestions?

  74. kev / January 28th, 2009 4:20 am

    bugger - forgot the code markup:

    and just in case I got that markup wrong...

    1) swfobject.js
    2) swfmacmousewheel2.js
    3) swfaddress.js

  75. kev / January 28th, 2009 2:06 pm

    solved it.

    FYI: added a mousewheel event handler to the TextArea - this.dispatchEvent(event)

  76. lauren / February 1st, 2009 11:11 pm

    Hi, Thanks so much for this.
    I could really do with the AS2 version compatible with SWFObject2. Is this possible?

  77. Tadhg / February 13th, 2009 11:27 am

    Hi, thanks for sharing this, its a very cool project.
    Once issue I seem to have is that it breaks mouse wheel support on the browser window, so you can't scroll up and down the browser when your cursor is over flash content, all the mouse events are passed to flash. Is there any way to fix this? For instance once the display list has been traversed and if no mouse wheel events need passing through could the javascript be temporarily disabled to check the main browser window so it can scroll if it needs to?

    -T.

  78. Robert M. Hall / March 7th, 2009 3:27 am

    Hi all - thanks for the great bit of code - been using it for a while - and ran across a couple other threads, and implementations of mousewheel support for Flash on Macs. I had started using this a while back and have added several tweaks to fix most of the issues people have had with it. Specifically if you register multiple SWFobject ID's on a page my changes only dispatch the mousewheel event to the items that were registered, and only the current id being actively scrolled. It also prevents the null object on PC's without having to put an explicit check on the page when you attach it, as well as checking for Safari on PC's and making that work. Those seemed to be the biggest issues.

    Feel free to grab it from here: http://www.impossibilities.com/v4/publications/downloads/

  79. Railk / March 8th, 2009 12:32 am

    Robert>> Since you're relying on the modified version i made some time ago (see my post somewhere up in the comments), for the PC safari fix to work, you need to provide the modified .as and put a flash var as explained in the readme.txt of my rar file, otherwise it'll not work with just the .js modification.

  80. darscan / March 10th, 2009 1:16 am

    Be sure to cast a vote for the bug itself in the Adobe bug tracker:

    http://bugs.adobe.com/jira/browse/FP-503

  81. Robert M. Hall / March 10th, 2009 6:00 am

    Hi Railk - thanks for the heads up. I actually had uploaded the wrong files by mistake (blame it on the late hour of the evening when I posted) I've revised the upload with a cleaner version that fixes some additional issues, and makes a note about your versions. :) I also put together a similar modification for the AS2 code and made that available also. Thanks for catching that! -Rob

  82. Jason / March 11th, 2009 2:31 pm

    I just wanted to point out that if you are trying to use the AS2 version, you will have to develop this on a Windows machine to be able to test the scrolling "in Flash". If you are on a Mac you have to test it in a browser.

  83. Dro / March 11th, 2009 7:13 pm

    You're a genius. Works great!

  84. Dro / March 11th, 2009 7:33 pm

    Found one teeny tiny bug. If you try to use the mouse wheel before the flash object grabs focus an error is thrown.

    It can be fixed by checking in function _externalMouseEvent
    if(_clonedEvent == null) return void;

    There's probably a more elegant fix, but that was a quick one I found.

    This was the error:
    TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at com.pixelbreaker.ui.osx::MacMouseWheel/_externalMouseEvent()
    at Function/http://adobe.com/AS3/2006/builtin::apply()
    at flash.external::ExternalInterface$/_callIn()
    at ()

  85. Dro / March 11th, 2009 9:17 pm

    I noticed others have the problem with the mouse wheel feature being disable on the browser level when using this plugin. This little piece of code should fix that.

    Replace the for loop inside deltaDispatcher to:

    for(var i=0; i

  86. dedser / March 17th, 2009 11:32 am

    Hi. I have a problem here. When I import the MacMouseWheel class nothing shows when i view my site in my browser (Safari 4b and Firefox 3.0.7 both os x). Anyone knows why that is?

  87. Jan Poulsen / March 18th, 2009 12:36 am

    When I use safari 4 and scroll there seems to be some kind of extra acceleration when compared to Firefox and Internet Explorer?

    Do you have this issue too? And how can it be solved?

  88. dedser / March 18th, 2009 11:32 am

    Never test local. A whole day of trying to fix my problem only to find out that it works perfect online.

  89. yellowCub / March 24th, 2009 5:49 pm

    Same problem here dedser, only your comment saved me 3/4th of my day. Publishing to Safari, Firefox, etc with the class imported and implemented caused the SWF to not play. I could see that the SWF and javascript were loaded via the activity monitor, but nothing was being displayed in the player.

    Could someone explain why we cannot test the class/javascript locally? I understand why the class won't work in the local Flash Player...no javascript needed to play the SWF, but why not the local browser?

    Other than that...life saver. Great utility class, so easy to use on the AS3 side. Anyone heard any Adobe plans to remedy the oversight?

  90. yellowCub / March 24th, 2009 6:47 pm

    ...it's a security setting in the flash player. I did not receive the normal security warning about the "Flash Player has stopped a potentially unsafe operation", but my colleague did.

    Get to your Global Security Settings for Flash Player (http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html OR just right click on your browser flash player and click Privacy>Advanced) Make sure that the location you are testing from is 'trusted.' This has to be done to make sure that your HTML and js can communicate correctly.

    Thanks again for the mouse wheel class. Great stuff!

  91. Loan Modification / March 26th, 2009 3:24 pm

    I really like the work that has gone into making the post. I will be sure to tell my blog buddies about your content keep up the good work. Thanks

  92. Stop Foreclosure / March 26th, 2009 3:25 pm

    Thank you for the work you have put into this post, it helps clear up some questions I had. I will bookmark your blog because your posts are very informative. We appreciate your posts and look forward to coming back.

  93. Florida Title Company / March 26th, 2009 3:27 pm

    Nicely said, I enjoy the time that it took to research and write. Great work

  94. Short Sale Training / March 26th, 2009 3:28 pm

    Very creative content, some of the best content I have seen today. Keep up the great work.

  95. Online Resource / March 28th, 2009 1:49 am

    Short but very intelligent codes.
    Thanks for share.

  96. Barackoli / April 20th, 2009 7:35 am

    Thank so much..this is excellent post

  97. jacobmake / April 22nd, 2009 9:04 pm

    man... this thread is getting loooong. Anybody else finding conflict w/ 'swffit'? I can only seem to get one two work at a time.

  98. Criminal Background Check / April 25th, 2009 11:50 am

    Thanks for a nice and informative site. Somehow I was drawn to reading the post and I learned a lot. Have a nice day!

  99. mark / April 28th, 2009 3:02 pm

    hi, there!
    great work, but are there any news on the subject of scrolling the rest of the page:

    Tadhg: "Once issue I seem to have is that it breaks mouse wheel support on the browser window, so you can't scroll up and down the browser when your cursor is over flash content, all the mouse events are passed to flash. Is there any way to fix this? For instance once the display list has been traversed and if no mouse wheel events need passing through could the javascript be temporarily disabled to check the main browser window so it can scroll if it needs to?"

  100. Michael / April 28th, 2009 11:31 pm

    I am trying to retrofit an AS2 site with MacMouseWheel, the comments must be closed on the AS2 version of this site.

    I am having some problems retrofitting an AS2 site with pixel breaker macmousewheel. I have called the correct class per the website in actionscript that used to work with the original flash class.

    var mouseListener:Object = new Object();
    mouseListener.onMouseWheel = function(delta) {
    addy = -delta * 10;
    yy = scroller._y;
    hh = scroller._height;
    if (yy + hh + addy > mask._y + mask._height) {
    addy = mask._y + mask._height - yy - hh;
    }
    if (yy + addy .

    swfobject.embedSWF('background.swf', 'coop', '100%', '100%', '9', 'expressInstall.swf', {}, {menu: 'false'}, {id: 'coop'});
    swfmacmousewheel.registerObject(attributes.id);

    Any ideas on what I am doing wrong? Again, this is AS2. This is a swf within a swf within a swf calling the MouseWheel class. Also, it still seems to work in IE7 which would indicate that it should be working...Any help would be appreciated.

    Thanks.

  101. Rebecca Ward / May 6th, 2009 2:04 am

    Hi, I have a client who likes your software. Do you have any specific licensing terms that I should make them aware of?

    Thanks.

  102. Dragee / May 7th, 2009 2:33 pm

    @Michael

    Hey there. I managed to get this working with an AS2 website.

    Try this:

    var flashvars = {};
    var params = {};
    params.scale = "noscale";
    params.wmode = "window";
    params.allowfullscreen = "true";
    var attributes = {};
    attributes.id = "coop";

    swfobject.embedSWF("FLUID.swf", "myContent", "100%", "100%", "9.0.0", "expressInstall.swf", flashvars, params, attributes );
    swfmacmousewheel.registerObject(attributes.id);

    Then modify your Flash as described in the older AS2 version of macMouseWheel.

    Drop me a mail if you need help. chewydragee44 [at] yahoo.co.uk

  103. Cephe Kaplama / May 8th, 2009 12:56 pm

    thanks for the great bit of code

  104. Claire / May 11th, 2009 1:06 am

    Hello! Could you please confirm that SWFMacMouseWheel is licensed under the MIT license?

    Thanks!
    Claire

  105. video / May 20th, 2009 11:53 am

    thanks for contribution. very nice and useful article.

  106. دردشة مصر / May 21st, 2009 3:45 pm

    thaaaanks

  107. betway poker / May 26th, 2009 11:49 am

    thanks for your help

  108. Jimmi / May 27th, 2009 9:39 am

    It seems that there is a problem getting the right values for the crtlKey, altKey and shiftKey properties in the event dispatched by MacMouseWheel. If you press e.g the alt key while not moving the mouse and then start scrolling (still not moving the mouse) the altKey property on the mouse event is not correct.

    Looking at the code this makes perfect since MacMouseWheel captures the _clonedEvent (which is effect is the event that is received by the application) on mouse moves only. I fixed the problem by adding key down and up event listeners to MacMouseWheel and letting the event handlers modify the current _clonedEvent.

    See the source code below.

    Feel free to add these fixes to your code.

    Thanks,

    Jimmi

    private function _keyDownHandler(event:KeyboardEvent):void {
    switch(event.keyCode) {
    case Keyboard.CONTROL:
    _clonedEvent.ctrlKey = true;
    break;
    case Keyboard.SHIFT:
    _clonedEvent.shiftKey = true;
    break;
    case 18:
    _clonedEvent.altKey = true;
    break;
    }
    }

    private function _keyUpHandler(event:KeyboardEvent):void {
    switch(event.keyCode) {
    case Keyboard.CONTROL:
    _clonedEvent.ctrlKey = false;
    break;
    case Keyboard.SHIFT:
    _clonedEvent.shiftKey = false;
    break;
    case 18:
    _clonedEvent.altKey = false;
    break;
    }
    }

  109. evden eve nakliyat gazioglu naklyat / May 31st, 2009 9:15 am

    www.gaziogluevdenevenakliyat.com
    evden eve taşıma
    www.turkmenoglunakliyat.com
    evden eve nakliyat
    evden eve nakliye
    evden eve taşıma
    even eve nakliyat
    istanbul ev taşımacılık
    istanbul evden eve taşıma
    nakliyat
    nakliye
    ev depolama
    istanbulda nakliye firması
    istanbulevdeneve
    istanbul evden eve
    nakliye firmaları
    ucuz nakliyat
    nakliye fiyatları
    şehirler arası nakliyat
    şehirlerarası evden eve nakliyat
    şehirler arsı ucuz nakliyat
    şehirler arası nakliye
    şehirler arası evden eve nakliyat
    şehirlerarası taşıma

  110. Felix / May 31st, 2009 2:14 pm

    Hi!
    Thanks for this great add on!
    Do you think it is possible to add support for the two finger scroll feature? So that one can do diagonal scroll?
    That would be awsome.

    Best Regards..

  111. guitaristmaniac / June 1st, 2009 1:15 pm

    This is great feature and I want to implement it the way it goes.

  112. Flexer / June 3rd, 2009 7:38 pm

    Gabriel, you rock!!

  113. Aaron Beall / June 6th, 2009 1:43 am

    Am I missing something that this solution does not dispatch MOUSE_WHEEL events for the stage?

  114. Betclic bonus / June 7th, 2009 2:22 am

    Thanks for contribution. very nice and useful article

  115. Sportingbet / June 7th, 2009 5:48 pm

    Great job, thanks a lot.

  116. Dro / June 7th, 2009 9:51 pm

    Hi, I have a fix to the scroll wheel disabling all the mouse wheel events. I tried posting it here a couple of months ago, but it looks like it never made it into the comments. Click on my name for the link to my site.

    Sandro

  117. neon / June 12th, 2009 7:35 pm

    Your site is very easy in terms of expression and open. I think everyone who enters your site is very gratifying, but also sharing a very nice opportunity to give ...

  118. Felix / June 14th, 2009 10:42 am

    Hi,

    Just noticed that the new safari 4 (not the beta) doesn work well with macMouseWheel.
    I get little or no delta action when scrolling.
    Just so you know, great work.

  119. TV studio film lighting / June 15th, 2009 10:44 am

    good,thanks.

  120. HD video camera battery / June 15th, 2009 10:45 am

    great blog.thanks.

  121. HD LCD monitor / June 15th, 2009 10:59 am

    It's nice, I am learning, thank you

  122. Background Check / June 16th, 2009 6:15 pm

    Thanks for the mac update, it was very interesting to read.

  123. demianovics / June 16th, 2009 6:17 pm

    if (swfmacmousewheel) { swfmacmousewheel.registerObject(attributes.id); }

    as swfmacmousewheel returns null if !mac, there is no .registerObject function. so check if swfmacmousewheel is != null before.

  124. Roxy palace / June 20th, 2009 9:28 am

    Very cool , thanks a lot.

  125. neon / June 20th, 2009 7:53 pm

    Everything is very open and very clear explanation of issues. was truly information. Your website is very useful. Thanks for sharing.

  126. Tom / June 22nd, 2009 12:21 pm

    This works well in firefox, but on safari 4 on a mac the delta value is less than normal. For example the delta value range is only -1 - 1. Not any higher? I'm using the lastest swfobject. But your test doesn't work very well in safari 4.
    Any ideas?

  127. hosting / June 24th, 2009 2:16 pm

    Very creative content, some of the best content I have seen today. Keep up the great work.

  128. Trevor / June 25th, 2009 11:16 pm

    yep, safari 4 is wonky.

  129. 乐清网站制作 / June 26th, 2009 3:02 pm

    thanks for this.

  130. betclick / June 30th, 2009 5:00 am

    very good work

  131. söve / June 30th, 2009 1:45 pm

    Great work.Thanks a lot.

Leave a reply

*
To prove that you're not a bot, enter this code
Anti-Spam Image