Question : Flex CountDown Timer

Hello All,
working on a timer base component.
there are to buttons on the application where one is pause and second is play.
when i click on pause i need to pause the countdown clock and when i click play i need to restart the countdown again from where it has stopped.
could someone help me in achieving this.
Attachments:
 
Main Application
 
 
Count Down Component
 

Answer : Flex CountDown Timer

If you really want to pause and later on restart the countdown from where it stopped you have to store the date:

1) In CountDownClock add a private variable:

         private var _date:Date;

2) in the init() function initialize it right before starting the timer:

        _date = new Date();

3) Adapt your onTick() method like this:

public function onTick(evt:TimerEvent):void
{
     _date.setTime(_date.getTime() + 1000); // increment with one second

      // updates the clock display
      this.text = getCountDown(countDownDate.getTime() - _date.getTime());
}

But once again, once you have paused the countdown, restarting it will never give you the correct result.
Since pausing the countdown doesn't mean the time stood still.
Its your choice which implementation you want.
Random Solutions  
 
programming4us programming4us