开发者

Application timeout feature

I am developing an AIR 2.0 application, and would like to put an inactivity timeout feature into it. (i.e: if the user doesn't press a key for 5 minutes then the application logs the user out. I have implemented the native timeout features available in the flash.utils library, and listen for mouse or keyboard events to clear / reset the timeout in my main MXML. The only problem is that my application uses TitleWindows and the keyboard events don't appear to bubble up (or back) into the main Mxml where I'm listening for them. Therefore my app thi开发者_如何学Gonks that there is inactivity even when keys and mouse events are firing in the Title windows.

Is there a way that I can inherently listen for keyboard and mouse events globally? the prospect of adding listeners to every TitleWindow (and checking to see if it is open or not) seems quite daunting.

Many thanks for any help.


From anywhere in a UIComponent (probably the main UI class):

private function onCreationComplete():void
{
   stage.addEventListener(KeyboardEvent.DOWN, onKeyboard);
}

private function onKeyboard(e:KeyboardEvent):void
{
   // do something
}


I think you're running into a focus issue which is always frustrating, check my answer here-

Event listener to keyboard event not listening in a module

Try the textinput suggestion at bottom of answer to test if this is the problem.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜