Friday, February 24, 2006

mouseWheel has issues when used with wMode=transparent

I've been facing a lot of issues with wmode='transparent'. (We needed it to be transparent because we had to show a java applet showing a 3D interactivity above the SWF in our app).

I have come across a few blog posts about the transparent setting for wmode making the input text fields appear without a I-beam mouse pointer in FF.

The recent one that I see is that when wmode = transparent, the scrollTarget being sent as the second parameter to the onMouseWheel event handler function is the path to a movieclip tats a few (about 50- 60 , i guess) pixels above / below the actual movieclip that the mouse is currently on. I tried turning off wmode and it works as expected.

I put together a test file to test this (I tested it out on both Flash 8 and MTASC) , and I see the same problem there.
Here is the test Class:

class App {
function App(ref) {
var o:Object = new Object();
o.onMouseWheel = function(n:Number, s:String) {
ref.log.text += s+"\n";
static function main(ref) {
var o:App = new App(ref);
function drawMe(timelineRef) {
var w:Number = Stage.width;
var h:Number = Stage.height;
var bg_mc:MovieClip = timelineRef.createEmptyMovieClip("bg_mc", timelineRef.getNextHighestDepth());
var box_mc:MovieClip = timelineRef.createEmptyMovieClip("box_mc", timelineRef.getNextHighestDepth());
bg_mc.lineStyle(1, 0xFF0000, 100);
bg_mc.beginFill(0xFF0000, 100);
bg_mc.moveTo(0, 0);
bg_mc.lineTo(w, 0);
bg_mc.lineTo(w, h);
bg_mc.lineTo(0, h);
bg_mc.lineTo(0, 0);
box_mc._x = box_mc._y=100;
box_mc.lineStyle(1, 0x00FF00, 100);
box_mc.beginFill(0x00FF00, 100);
box_mc.moveTo(0, 0);
box_mc.lineTo(w/4, 0);
box_mc.lineTo(w/4, h/4);
box_mc.lineTo(0, h/4);
box_mc.lineTo(0, 0);
timelineRef.createTextField("log", timelineRef.getNextHighestDepth(), 0, 0, 200, 0);
timelineRef.log.autoSize = true;

And in my FLA, I have the following code:


Does anybody else see this? is this a known issue? If it is,dDo we have a technote about all these known issues with wmode?


We developed (actually a collegue of mine wrote it all) a work around. As you might guess, we resorted back to hitTest. We have a onMouseWheel listener and when it triggers, we dont use the target that Flash player returns itself. Instead we do a hitTest with _xmouse and _ymouse and figure out the bounds. Though not a great solution, it solves the purpose. Am planning to think about doing something generic enough for this. Let me think!


EvertRooftop said...

I also had a lot of issues with wmode="transparent", just in firefox though..

Haven't been able to find a solution yet...

Arul said...

thats another one!

Anonymous said...

there was flash 8 bug with 9-slice.

marvin said...

you may check out

for a clean solution for this "bug" in FF 3.5 and IE8.

Marvin said...

this one's the quickest and safest solution i've found so far: