Flash Player Mousewheel event not firing

By admin on 27/01/2011

I'm not sure if this is an issue with a recent Flash Player, Browser updates, OS, Hardware or whatever but in a recent application I noticed really poor responsiveness on mousewheel scrolling. This was also picked up by the client so it was time to sort it.

These sort of issues are always a real pain as it's a problem not expected, not budgeted for and almost certainly going to eat a lot of time. Oddly I couldn't find much else out there on the same issue. Fortunately one of the few resources I did find in this case someone had already done the hard work for us!

Jake over at byHook posted some extremely handy classes which use javascript injection to pickup the js mousewheel events in the browser which are much more reliable. It then uses the info from these events to fire off a new mouseevent in Flash.

It was built for use in Flash projects but works seamlessly in Flex also:

Import the classes and add the following to the APPLICATION_COMPLETE event:

private function onAppComplete(e:FlexEvent):void

{

MouseWheelEnabler.init(this.stage);

}

And that's all, much more consistent and responsive scrolling! It did still feel a little slow for my taste so I added the following bumpDelta method to the system manager to speed things up:

private function onAppComplete(e:FlexEvent):void

{

MouseWheelEnabler.init(this.stage);

systemManager.addEventListener("mouseWheel", bumpDelta, true);

}

public function bumpDelta(event:MouseEvent):void

{

event.delta *= 2;

}

Like I said, couldn't find much when searching on this issue hence my re-posting of Jake's solution. I was specifically looking for Flex so thought this might help someone else in the future but all props definitely due to byHook for the code.