Timer using setInterval in Flex

Below example shows to set a time interval to show the values from an Array.

<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml&#8221; layout=”absolute”  creationComplete=”onCreate(event)”>
<mx:Script>
<![CDATA[
private var Count:int=0; private var ServerTimer;
private function onCreate(e:Event):void
{
ServerTimer=setInterval(TimerFunction,1000)   // Calling a function after 1 sec.
}
private function TimerFunction():void
{
ServerName.text=Count.toString()  //Show the count value in the Label
Count+=1 // Increasing count value by 1
}
]]>
</mx:Script>
<mx:Label text=”Starting” fontSize=”40″ id=”ServerName”  x=”67″ y=”83″> </mx:Label>
</mx:Application>

Output

/**/