title: Flex Timer example
body: <p>I am trying to use timer in flex. I referred to this example : <a href="http://blog.flexexamples.com/2007/08/14/creating-a-simple-timer-in-flex-with-the-flashutilstimer-class/" rel="nofollow"><code>Timer : blog.flexexamples.com</code></a>.</p>
  
  <p><strong>Here is what I want to achieve:</strong></p>
  
  <blockquote>
    <p>I want to start the timer, showing <strong>minutes elapsed</strong> since timer
    started. It should be independent of the region you are in.(
    irrespective of whatever zone you are in, timer should work fine in
    every zone).</p>
    
    <p>Timer should continue, unless some button is clicked, where I want to
    show the time elapsed in minutes, in an Alert Box and then timer should start again from 0 onwards.</p>
  </blockquote>
  
  <p>I tried my example, but it is not working properly.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
                  layout="vertical"
                  verticalAlign="middle"
                  backgroundColor="white"
                  creationComplete="init()"&gt;
  
      &lt;mx:Script&gt;
          &lt;![CDATA[
              import flash.events.TimerEvent;
              import flash.utils.Timer;
  
              import mx.controls.Alert;
              private const TIMER_INTERVAL:Number = 10;
  
              private var baseTimer:int;
  
              private var t:Timer;
  
              private function init():void {
                  t = new Timer(TIMER_INTERVAL);
                  t.addEventListener(TimerEvent.TIMER, updateTimer);
              }
  
              private function updateTimer(evt:TimerEvent):void {
                  var d:Date = new Date(getTimer()-baseTimer);
                  var min:String = (d.minutes).toString();
                  var sec:String = (d.seconds).toString();
  
                  counter.text = String(min+"."+sec);
              }
  
              private function startTimer():void {
  
                  baseTimer = getTimer();
                  t.start();
              }
  
              private function stopTimer():void {
                  t.stop();
              }
          ]]&gt;
      &lt;/mx:Script&gt;
  
      &lt;mx:ApplicationControlBar dock="true"&gt;
          &lt;mx:Button label="Start timer" click="startTimer()" /&gt;
          &lt;mx:Button label="Stop timer" click="stopTimer()" /&gt;
      &lt;/mx:ApplicationControlBar&gt;
  
      &lt;mx:Label id="counter" fontSize="96" /&gt;
  &lt;/mx:Application&gt;
  </code></pre>
  
  <hr>
  
  <p>Can somebody tell what is the problem ? How to solve it ?</p>
  
  <p><strong>EDIT :</strong> 
  If I run this example on my pc, timer starts from 30.0 till it reaches 59.59 and then it turns back to 0.0 and then starts again......Now What I want is to start from 0.0 and continue counting minutes till some button is clicked ... and this should work in any time zones</p>