XP Firefox 上 Flash 中的重复鼠标滚轮事件

发布于 2024-08-16 21:21:29 字数 918 浏览 8 评论 0原文

在 Firefox 3 中,我的 Haxe/Flash 应用程序中的所有 mouseWheel 事件都会触发两次。这似乎只发生在 Windows 版本的 Firefox 中;它不会发生在 IE 或 Opera 中,也不会发生在 Linux 中。

这是一个已知问题,还是我做错了什么?是否有一种解决方法,不涉及诸如检查用户代理并忽略所有其他事件之类的疯狂事情?

更新:我在旧的 powerbook 上进行了测试(在合并 Pixelbreaker 的 SWFMacMouseWheel 脚本后),发现虽然 OS X 版本的 Firefox 表现正常,但 Safari (3.2.1) 的事件也加倍。

我还在 AS3 中编写了一个简单的测试,以确保这不是 Haxe 的错;我也有同样的行为。代码如下,您可以在此处尝试一下。

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"); });
    }
}
}

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"); });
    }
}
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

只为一人 2024-08-23 21:21:29

尽管我多次使用滚动条进行导航,但我还没有遇到过这种情况。但是,我在使用 wmode(即不是默认窗口模式)时遇到了不一致的情况,例如“透明”或“不透明”。

如果您使用的是 wmode(例如嵌入 HTML 中的 wmode="transparent"),请尝试禁用它并查看是否会改变行为。

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.

小…红帽 2024-08-23 21:21:29

我也遇到了这个问题 - 由于滚轮鼠标通过 3-5 段控制滑块位置,因此这是一个明显的故障。

我最终创建了一个计时器,并确保在允许新的轮子事件之前经过 10 毫秒。这不是一个完美的解决方案,但 10 毫秒感觉还算合理。

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
} 

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
} 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文