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
-
import com.pixelbreaker.ui.osx.MacMouseWheel;
-
-
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
-
var vars = {};
-
var params = { scale:'noScale', salign:'lt', menu:'false' };
-
var attributes = { id:'testObject', name:'testObject' }; // give an id to the flash object
-
-
swfobject.embedSWF("test_as3.swf", "flashContent", "100%", "100%", "9.0.0", "js/expressInstall.swf", vars, params, attributes );
-
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
26 Comments so far
Leave a reply
Thanks gabe! Very nicely done!
God bless you, your children, the children of your children for this wheel thing :)
Thanks! You're my new best friend! :)
Yaaaaayyyyyy!!!! Thanks so much. A real lifesaver! And nicely implemented too. I like how you've stuck to the style of SWFObject 2.0
Thanks! You've made me not look so lame!
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.
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.
You need to check out Chumby.com
With your mad flash skills, you'd have some fun with it.
MyridoM
This works wonders. Thanks so much!
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?
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.
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.
davi: I'll have a look into this...
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 ;-)
This works wonders. Thanks so much!
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.
Yep I just tried it on Safari for windows.. Doesn't work :/ (Safari Ver 3.1)
This class was so simple to implement and solves such a huge problem. Thanks very much
Gabriel, you're distributing this with svn files included starting at /ui level. Thanks for sharing your code.
I don't understand, i have safari 3.1 on windows, and i can't run the demo online ?
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 !
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 !
You code just made in onto a MOMA minro site
http://media.moma.org/subsites/2008/olafureliasson/#/intro/
Your code just made in onto a MOMA minro site
http://media.moma.org/subsites/2008/olafureliasson/#/intro/
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.
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