2 Replies Latest reply on May 20, 2008 12:36 PM by ntsiii

    Adding hours to Flex timer

    nrutter Level 1
      I am attempting to add hours to my Flex timer and it is not working? The hour column starts at 18....Any ideas

      private const HOUR_MASK:String = "00";
      private const MIN_MASK:String = "00";
      private const SEC_MASK:String = "00";
      private const MS_MASK:String = "000";
      private const TIMER_INTERVAL:int = 10;

      private var baseTimer:int;
      private var t:Timer;

      private function init():void{
      t = new Timer(TIMER_INTERVAL);
      t.addEventListener(TimerEvent.TIMER, updateTimer);
      baseTimer = getTimer();
      t.start();
      }


      private function updateTimer(evt:TimerEvent):void {
      var d:Date = new Date(getTimer() - baseTimer);
      var hour:String = (HOUR_MASK + d.hours).substr(-HOUR_MASK.length);
      var min:String = (MIN_MASK + d.minutes).substr(-MIN_MASK.length);
      var sec:String = (SEC_MASK + d.seconds).substr(-SEC_MASK.length);
      var ms:String = (MS_MASK + d.milliseconds).substr(-MS_MASK.length);
      callTime.text = String(hour + ":" + min + ":" + sec);
      }

      <mx:TextInput id="callTime" fontSize="10" editable="true" width="82" height="19"/>