Archive for category Mouse Wheel

Mouse Wheel problems and no answer

My search of the day is about the mouse wheel. So I’m making this scrollbar Class and to make a full fledge scrollbar you need to make it work with the Mouse Wheel. Ok, this part is not so bad, I look around a bit and I find this:

1
2
3
4
5
6
7
8
9
10
11
12
13
var mouseListener:Object = new Object();
mouseListener.onMouseWheel = function(wheelNum:Number)
{
if (wheelNum > 0)//rolling wheel toward the screen
{
//your code
}
else if (wheelNum < 0)//rolling wheel away from the screen
{
//your code
}
}
Mouse.addListener(mouseListener);

This works out pretty well when testing inside the Flash authoring tool. The interesting part of this code it the Mouse.addListener part because in ActionScript 2, there is no mouseWheel event on MovieClips, you have to use the global object Mouse to catch the mouse wheel. This can cause trouble because it won’t only catch the mouse wheel when the mouse is over the MovieClip, but at large, when the mouse is over the entire flash movie. You have to tweak it to make it work this way. I think this is resolved in ActionScript 3; most of the mouse events are renamed for consistency and there is a mouseWheel event on MovieClips.

My trouble was that when I tried my movie in a browser, sometimes, the mouse wheel didn’t work. At first I was thinking it was because my SWF that had the mouse listener in it was loaded in another SWF. When I make a website, I most of the time make an external preloader; this way it will preload the MovieClips I export for ActionScript. I found out that the trouble was actually coming from the SWFObject. When I was using SWFObject in my HTML, the mouse wheel wouldn’t work in FireFox and Opera (it works fine in Explorer). I looked around a bit to find other people with the same problem and found none… So I did some testing on my own.

At first I tried getting the new version of SWFObject here but that didn’t do it. I also 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 SWFObject and UFO: SWFFix. There it was, the answer to my problem. Trouble is, it is only in alpha stage and its not a stable release, but in my case it worked real fine. I will check for new version often to be the more stable as possible, but for now I am pleased with this option.

I have another point I want to make, I wanted to start deep liking my site to enable more browser options (back, foward, history) and the script I had found was based on SWFObject, so I can’t use it in this case.

, , , ,

5 Comments