如何创建跨多台机器具有一致性能的闪存程序?
我想创建一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用
getTimer()
- 这意味着您的数据带有自应用程序启动以来的毫秒数时间戳 - 无论处理器速度等如何。示例:
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:
将 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)