Using Timer Class we can raise an Event at specified Time and even at the completion of the specified Time.
The below example uses two events, one if fired for every sec and other one after the completion of the Time specified.First define a var of type Timer with time specified ,which specifies the time interval you wanted to raise the event.
var mTimer:Timer=new Timer(1000,5);//ticks for 5 sec’s
Then add events to it for every sec and completion of specified time like below.
mTimer.addEventListener(TimerEvent.TIMER,Countsec);
mTimer.addEventListener(TimerEvent.TIMER_COMPLETE,Comple);
Now start time.
mTimer.start();
Define the two function you wanted to call for events.like below.
private function Countsec(e:TimerEvent):void
{
lbltime.text=e.target.currentCount;
}
private function Comple(e:TimerEvent):void
{
lbltime.text=”Time Complete”;
}
Here lblTime is the Label Control id in Flex.
<mx:Label id=”lbltime” x=”374″ y=”167″ width=”369″ height=”61″ fontWeight=”bold” fontSize=”30″/>
Thats all the Time is set for 5 sec, Enjoy the code.

June 29, 2008 at 5:06 pm |
thanks
September 15, 2008 at 1:18 am |
nice ticket…simple and it works fine
May 27, 2009 at 8:40 am |
saviour code,
thank you bro..
August 12, 2009 at 2:22 pm |
Thank you, its great for beginners
Thank you