Monday, December 29, 2008

Monitoring System Idle State in AIR


Please look this code:

NativeApplication.nativeApplication.idleThreshold = 120;

NativeApplication.nativeApplication.addEventListener(Event.USER_IDLE, idlefunction(event:Event) {trace("Idle");} );

NativeApplication.nativeApplication.addEventListener(Event.USER_PRESENT, presentfunction(event:Event) { trace("Present");} );


Note:
Using the idleThreshold property, the specified interval( in seconds) are set, The system is reaching the idle state, upto specified seconds, Event.USER_IDLE is fired and any interrupt to the system (keyboard, mouse or input devices) is done, Event.USER_PRESENT is fired. Its very helpful to screen saver samples.