如何创建跨多台机器具有一致性能的闪存程序?

发布于 2024-11-16 00:24:12 字数 100 浏览 2 评论 0原文

我想创建一个 flash 程序来跟踪鼠标和键盘生物识别信息,例如鼠标移动速度、点击率、击键长度等。如果用户在具有不同处理器速度的多台机器上重复他/她的操作,我如何确保我将记录相同的数据?

I want to create a flash program that tracks mouse and keyboard biometrics such as mouse movement speed, click rate, length of keystrokes and so forth. How can I ensure that if a user duplicates his/her actions across multiple machines with varying processor speeds I will record the same data?

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

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

发布评论

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

评论(2

秋意浓 2024-11-23 00:24:12

您可以使用 getTimer() - 这意味着您的数据带有自应用程序启动以来的毫秒数时间戳 - 无论处理器速度等如何。

示例:

public class DocClass extends Sprite
{
    // vars
    private var _log:Array = [];

    /**
     * Constructor
     */
    public function DocClass()
    {
        stage.addEventListener(MouseEvent.CLICK, _click);
    }

    /**
     * MouseEvent.CLICK
     */
    private function _click(e:MouseEvent):void
    {
>>      _log[_log.length] = {time:getTimer(), data:"CLICK"};
    }

    /**
     * Output the log
     */
    public function outputLog():void
    {
        var i:Object;
        for each(i in _log)
        {
            trace(i.time + ": " + i.data);
        }
    }
}

You could sign all your data with a Number given by getTimer() - this will mean your data is timestamped with the amount of milliseconds since the application was launched - regardless of processor speed, etc.

Example:

public class DocClass extends Sprite
{
    // vars
    private var _log:Array = [];

    /**
     * Constructor
     */
    public function DocClass()
    {
        stage.addEventListener(MouseEvent.CLICK, _click);
    }

    /**
     * MouseEvent.CLICK
     */
    private function _click(e:MouseEvent):void
    {
>>      _log[_log.length] = {time:getTimer(), data:"CLICK"};
    }

    /**
     * Output the log
     */
    public function outputLog():void
    {
        var i:Object;
        for each(i in _log)
        {
            trace(i.time + ": " + i.data);
        }
    }
}
兮子 2024-11-23 00:24:12

将 SWF 的帧速率设置为较大的值,如 60 fps(AFAIK,较大的数字不会带来加速),并保持图形效果和代码计算简单。这样你就可以获得高帧率。您需要它,因为您的代码仅在播放器渲染的帧之间唤醒,并且大 fps 将提高时间分辨率。
然后使用 getTimer 给出的实时测量数据。如果您的应用程序能够以 60 fps 运行,则一帧将持续 1000/60 = 16.666 毫秒,因此您可以希望您的数据如此精确。
(@Marty Wallace:getTimer() 返回 int,而不是 Number)

Set frameRate of your SWF to something big like 60 fps (AFAIK, bigger number will give no speedup) and keep graphic effects and code computations simple. This way you'll get high frame rate. You need it because your code awakens only between frames rendered by player, and big fps will increase time resolution.
Then measure your data using real time given by getTimer. If your application will be able to run at 60 fps, one frame will last for 1000/60 = 16.666 milliseconds, so you can hope your data is that precise.
(@Marty Wallace: getTimer() returns int, not Number)

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