Checking user is idle or not in AIR
Wednesday, December 17, 2008
This changes the label according to user is active or idle on system.
Please note this is for AIR only.
Please note this is for AIR only.
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="init()" layout="absolute">
<mx:Script>
<![CDATA[
private function init():void
{
NativeApplication.nativeApplication.idleThreshold = 5;
NativeApplication.nativeApplication.addEventListener(Event.USER_PRESENT, userActiveAlert);
NativeApplication.nativeApplication.addEventListener(Event.USER_IDLE, userIdleAlert);
}
private function userActiveAlert(ev:Event):void
{
lblUserStatus.text = "User came back :-)";
lblUserStatus.setStyle("color",StyleManager.getColorName("green"));
}
private function userIdleAlert(ev:Event):void
{
lblUserStatus.text = "User is idle :-(";
lblUserStatus.setStyle("color",StyleManager.getColorName("red"));
}
]]>
</mx:Script>
<mx:Label id="lblUserStatus" />
</mx:WindowedApplication>
Labels: Flex AIR Active User
0 Comments:
« back home
Post a Comment