Flex:检测用户空闲?
如何判断用户何时在我的 Flex 应用程序上闲置了 5 分钟?
当我说“空闲”时,我的意思是用户根本没有与应用程序交互。
谢谢!!
How can I tell when a user has been idle for say 5 minutes on my Flex app?
When I say "idle" I mean the user has not interacted with the application at all.
Thanks!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
另请参阅
系统管理器
。此方法适用于 AIR 或 Flash Player。您可以使用以下方式获取空闲时间(以不受支持的方式)
See also the
idle
event inSystemManager
. This approach works for AIR or Flash Player.You can get the idle time (in an unsupported way) using
由于这是一个 AIR 应用程序,我可以只监听 NativeApplication 上的 USER_IDLE 事件
Being that this is an AIR app, I can just listen for the USER_IDLE event on the NativeApplication
创建一个计时器,每次在应用程序级别捕获用户事件时都会重置该计时器。
如果计时器已结束,那么您就知道用户在设定的时间内处于空闲状态。
Create a timer that you reset everytime you capture an user event at the application level.
If the timer has ended, then you know the user has been idle for that set amount of time.
您可以使用以下代码获取超时:
You can get the time out by using following code:
@Michael Brewer-Davis
systemManager.addEventListener(FlexEvent.IDLE, onIdle)
对于鼠标事件效果很好。键盘事件呢?在
systemManager
监听键盘事件之前,您必须先关注某个元素。部分解决方案:
在
applicationComplete
事件中,我添加了以下行现在正在监听键盘事件。
缺点:仅在应用程序被点击至少一次后才有效。然后工作正常后
有没有办法让应用程序监听键盘事件而无需单击一次。有些人建议添加
stage.focus = this
。也不起作用。(仍然需要点击)@Michael Brewer-Davis
systemManager.addEventListener(FlexEvent.IDLE, onIdle)
works fine for mouse events.What about Keyboard events. You have to have focus on some element before
systemManager
listens to keyboard events.Partial Solution:
On
applicationComplete
event, I added the below lineNow keyboard events are getting listened.
Disadvantage: Only works after application is clicked atleast once. Then after works fine
Is there any way to make application listen to keyboard events without hassle of clicking once. Some suggested to add
stage.focus = this
. Did not work either.(Still click was needed)