<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical"
    xmlns:adartautils="com.adarta.utils.*"
      creationComplete="initApp()"
      viewSourceURL="srcview/index.html">
<mx:Script><![CDATA[
////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2007 Adarta.
// All Rights Reserved.
// You may copy the following code.
// Please notify me of any errors.
// This code is to be used for example only and there are no warranties or 
//    guarantees of any kind.
//
// If you have any suggestions or comments that may help me to better the code
// Please email me: tony(at)3alves.com or leave a comment at blog.3alves.com
//
////////////////////////////////////////////////////////////////////////////////
    import com.adarta.utils.IdleUserObject;
    import mx.controls.Alert;
    
private function initApp():void
{
}
private function StartWatch():Boolean
{
    timeout.addListener(ti);
    timeout.StartWatch(0.25,0,1);
    
    hbWorkingStatus.visible=true;
    
    return true;
}
private function StopWatch():Boolean
{
    timeout.StopWatch();
    
    hbWorkingStatus.visible=false;
    
    return true;
}
private function TimedOut():void
{
    txtHeader.text='Stop Watch Completed';
    Alert.show('Stop Watch Completed','Complete');
    hbWorkingStatus.visible=false;
    
}
]]>
</mx:Script>
<adartautils:IdleUserObject id="timeout"
    active="txtHeader.text='Running Stop Watch'"
    timedout="TimedOut()"
/> 

<mx:Canvas height="100%" width="100%">
 <mx:Text id="txtHeader" text="Time Out Tester" fontSize="18" />
 <mx:TextInput id="ti" width="200" text="type in here to prevent timeout" x="0" y="50" />
 <mx:VBox id="hbWorkingStatus" backgroundColor="#FFFF00"
     visible="false"
   backgroundAlpha="50" 

   borderStyle="outset" borderThickness="20"
   borderColor="#FF0000" borderSides="#FF0000" horizontalAlign="center" verticalAlign="middle" horizontalCenter="0" verticalCenter="0">
  <mx:Label id="lblWorkingStatus" 
      text="{timeout.secondsToGo} seconds left on the stop watch." 
      color="#000000" 
      width="95%" 
      height="100%"  
      textAlign="center" 
      fontWeight="bold"/>
 </mx:VBox>
 <mx:Button x="10" y="102" label="Start" click="StartWatch()"/>
 <mx:Button x="108" y="102" label="Stop" click="StopWatch()"/>
 <mx:Label x="208" y="52" text="{timeout.secondsToGo}" id="txtCounter"/>
</mx:Canvas> 
</mx:Application>