Hello,
I have this clock that runs as a countdown timer once a user logs into
the site. It works great until the user logs out. When they log back
in the counter no longer counts correctly. It is like there are 2
intstances of the clock running at the same time but I'm not sure how
to kill the first instance.
Clock code
private function getDaysUntil():void {
//setting the timer
var minuteTimer:Timer = new Timer(1000, 300);
minuteTimer.addEventListener(TimerEvent.TIMER, onTick);
minuteTimer.addEventListener(TimerEvent.TIMER_COMPLETE,
onTimerComplete);
minuteTimer.start();
}
public function onTick(evt:TimerEvent):void {
var minuteTimer:Timer = evt.target as Timer;
var lvSecondsRemaining:int = minuteTimer.repeatCount -
minuteTimer.currentCount;
var lvMinutes:int = lvSecondsRemaining / 60;
var lvSeconds:int = lvSecondsRemaining - ( lvMinutes * 60 );
var lvSecondsText:String = lvSeconds.toString();
if( lvSeconds < 10 ) lvSecondsText = "0" + lvSecondsText;
lblTimeUntil.text = lvMinutes.toString() + ":" + lvSecondsText;
}
public function onTimerComplete(evt:TimerEvent):void{
var minuteTimer:Timer = evt.target as Timer;
minuteTimer.reset();
minuteTimer.start();
tempXML.send();
}
private function stopTimer():void{
var minuteTimer:Timer = new Timer(1000, 300);
minuteTimer.reset();
minuteTimer.stop();
clearFormHandler();
}
Here is the logout button and the login button
<mx:Button label="Log Out" height="27" fillAlphas="[1.0, 1.0]"
fillColors="[#030000, #030000, #474545, #474545]"
borderColor="#DCDEDF" click="currentState=''; stopTimer();"/>
<mx:Button x="10" y="282" label="Login" id="Submit"
click="login_user.send();"
fontSize="14" themeColor="#FFA800" borderColor="#FA0202"
enabled="{formIsValid}" />
If the user is able to login
currentState = "Logged In";
tempXML.send();
getDaysUntil();
Any ideas how to get this to display right