views:

239

answers:

2

In Firefox 3, all the mouseWheel events in my haXe/Flash app are firing twice. This only seems to happen in the Windows version of Firefox; it doesn't happen in IE or Opera, and it doesn't happen in Linux.

Is this a known issue, or could I be doing something wrong? Is there a workaround that doesn't involve something crazy like checking the user agent and ignoring every other event?

Update: I tested on an old powerbook (after incorporating pixelbreaker's SWFMacMouseWheel scripts), and found that while the OS X version of Firefox behaves normally, Safari (3.2.1) is doubling the events too.

I also wrote a simple test in as3 to make sure it wasn't somehow haXe's fault; I got the same behavior. The code is below, and you can try it here.

package {
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.text.TextField;

public class Test extends Sprite {
    public function Test() {
        super();
        var tf: TextField = new TextField();
        tf.height = 300;
        addChild(tf);
        stage.addEventListener(MouseEvent.MOUSE_WHEEL,
                   function(e:MouseEvent):void { tf.appendText(e.delta+"\n"); });
    }
}
}
+2  A: 

I haven't encountered this, even though I've used the scroll bar for navigation a number of times. However, I have experienced inconsistencies when using a wmode (i.e. not the default windowed mode) such as "transparent" or "opaque".

If you are using a wmode, (e.g. wmode="transparent" in your embedding HTML), try disabling it and see if that changes the behavior.

richardolsson
Good to know, but I'm not touching wmode, and the problem's still there if I open the swf directly.
dw
A: 

I hit this too - and since the wheel mouse was controlling slider placement with 3-5 segments it was an obvious glitch.

I ended up creating a timer and making sure 10 milliseconds passed before allowing a new wheel event. Not a perfect solution, but 10 millis feels reasonable.

wheel_mouse_lock_time:Number = new Date().getTime();
...

public function image_wheel_zoom(e:MouseEvent):void {
  var current_time:Number = new Date().getTime();

  if (current_time - wheel_mouse_lock_time < 10){
    return; 
  }

  wheel_mouse_lock_time = ctime;

  //handle event
} 
ben