var timeLeft:int = 300 - minuteTimer.currentCount; this method turns seconds into minutes + fractional minutes or hours plus fractional hours, but doing hours minutes seconds will be the same idea.
private function formatTime(seconds:int):String { var timeLabel:String = seconds.toString() + " sec"; if (seconds > 3600) { timeLabel += " (" + Math.round(seconds*100/3600)/100 + " hrs)"; } else if (seconds > 60) { timeLabel += " (" + Math.round(seconds*10/60)/10 + " min)"; } return timeLabel; } --- In flexcoders@yahoogroups.com, "markcavins" <[EMAIL PROTECTED]> wrote: > > Hello, > > I have a very functional timer here that I am using but I would like > to get some advice on how to make it better. > > Code: > > private function getDaysUntil():void { > // creates a new five-minute Timer > var minuteTimer:Timer = new Timer(1000, 300); > > // designates listeners for the interval and completion events > minuteTimer.addEventListener(TimerEvent.TIMER, onTick); > minuteTimer.addEventListener(TimerEvent.TIMER_COMPLETE, onTimerComplete); > > // starts the timer ticking > > minuteTimer.start(); > } > > public function onTick(evt:TimerEvent):void { > var minuteTimer:Timer = evt.target as Timer; > lblTimeUntil.text = minuteTimer.currentCount.toString(); > } > > public function onTimerComplete(evt:TimerEvent):void > { > var minuteTimer:Timer = evt.target as Timer; > minuteTimer.reset(); > > minuteTimer.start(); > } > > > I would like to be able to split the time into minutes and seconds. > > Also I would like to get it to count down instead of up. >