Skip to content

User Idle Time (no mouse movement, no keyboard strockes) in Flex

June 10, 2009

So you want to lock the Flex application or keep track of the user’s idle time, or a lock timeout. The user idle time which is when the application is running, but the user does not press any keyboard strokes nor any mouse movements, the idleCounter launches every 100 ms.

To do this in Actionscript, we import:

import mx.managers.SystemManager;
import mx.events.FlexEvent;
import mx.core.mx_internal;
use namespace mx_internal;

On the creation complete of the Main Application (or use your own logic), place the code:

private function onCreationComplete():void {
   systemManager.addEventListener(FlexEvent.IDLE, userIdle);
}
private function userIdle(e:FlexEvent):void {
   if(e.currentTarget.mx_internal::idleCounter == 600){ // 60 Secs Elapsed while Being Idle!!
       // do something when the application has been idle for 60 seconds
       Alert.show("You have been idle for more than " + "60" + " minutes", "You have been signed out");
   }
}
Advertisements

From → Uncategorized

7 Comments
  1. sir, really ur code was usefull….thanks so much for ur clean and neat and simple explanation and the code …to implement idle timeout…..

  2. Anonymous permalink

    thank you very useful! great

  3. Anonymous permalink

    worked like a charm, flawless

  4. Beni permalink

    It’s not working for me , after sometime it’s starting the counter again – what can be the reson?

  5. Anonymous permalink

    How to manage idel timeout when windo is minimized ?

  6. In normal when we define timer we use 1000 equal to one second but in idle counter we use 600, why?

  7. santanu permalink

    Its beautiful . I am very much impressed .great MAN

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: