actionscript-3 - 如何修复 Flash 中的触摸延迟?

标签 actionscript-3 flash activex multi-touch lag

我在使用 AS3 的 TouchEvent 处理多点触控时遇到了奇怪的行为。触摸在某些情况下会明显滞后,但 Flash 的帧速率不会受到影响。就好像触摸被缓冲了,事件直到触摸几秒后才被调度。

我在这里上传了一个演示:https://youtu.be/omkCDqljfio

我只设法在 Flash Player 的 ActiveX 版本中重现了这种触摸延迟,但我已经在 Windows 10 和 Windows 7 中重现了它。所以我这里有一个托管我的 AS3 测试套件的 C# 应用程序, 但如果在 Internet Explorer 中查看 swf 也可以观察到。

由于我的应用程序已经涉及在 WPF 窗口中托管 SWF,因此我一直在尝试创建一个解决方案,在该解决方案中,触摸在 C# 中接收,然后与 AS3 通信。它会完美地工作,但当触摸发生在 WindowsFormsHost 上时,我的 WPF 窗口似乎没有接收到触摸帧。所以我必须解决另一个问题。

FlashDevelop 项目:https://drive.google.com/file/d/0BxC2eCzurT9rd0gzSGc4TUdQLTQ/view Visual Studio 解决方案:https://drive.google.com/file/d/0BxC2eCzurT9rUThmRHBKWHZmbzA/view

AS3 触摸事件:

        Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;

        stage.addEventListener(TouchEvent.TOUCH_BEGIN, stage_touchBegin);
        stage.addEventListener(TouchEvent.TOUCH_MOVE, stage_touchMove);
        stage.addEventListener(TouchEvent.TOUCH_END, stage_touchEnd);

创建导致延迟的显示对象,大概是因为触摸事件捕获阶段:

        for (var i:int = 0; i < 500; i++) 
        {
            Dotter.createBGDot(_bgLayer, _shapesOn ? Shape : Sprite);
        }

...

    static public function createBGDot(bgLayer:Sprite, dotClass:Class):void 
    {
        var dot:* = new dotClass();
        var color:Color = new Color();
        color.brightness = Math.random();
        dot.graphics.beginFill(color.color);
        dot.graphics.drawCircle(0, 0, Math.random() * 400 + 40);
        dot.x = Math.random() * bgLayer.stage.stageWidth;
        dot.y = Math.random() * bgLayer.stage.stageHeight;
        bgLayer.addChild(dot);
    }

我知道这是一种不寻常的情况,但我很感激任何有关如何解决这些问题的建议。

最佳答案

既然我已经使用了 Adob​​e Scout,我认为这毕竟是一个渲染问题。帧速率仍然显示 30fps,因为处理时间勉强达到 30fps 标记。降低帧速率可以解决问题。

尽管如此,当帧速率几乎没有下降时,触摸事件会有如此长的延迟仍然很奇怪。

关于actionscript-3 - 如何修复 Flash 中的触摸延迟?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44707906/

相关文章:

actionscript-3 - 弹性 AS3 : Find and remove elements from container of certain class

java - 用 float 替换整数的正则表达式

c# - 翻译我写到 C# 的 ActionScript 3 代码

actionscript-3 - 如何在 ActionScript 3 中设置/访问外部 swf 文件的动态文本字段?

c# - 使用新的 RDP 客户端保持事件代码失败

apache-flex - 在 Flex 中转换到接口(interface)时出现问题

javascript - 弹性 : Error #2048 when connecting to a WebSocket

flash - 缺少 AGALMiniAssembler

activex - 如何检查 ActiveX dll 是否已注册?

delphi - 如何编写可在MS Word/Excel/Powerpoint中使用的Delphi ActiveX控件?