views:

23

answers:

2
+2  Q: 

Timer alert - FIX

I have a timer alert:

private var cheat:Timer;

private function init():void {
    cheat = new Timer(2000, 1);
    cheat.addEventListener(TimerEvent.TIMER_COMPLETE, cheatProtection);
}

private function showAlert():void {
    cheat.reset();
    cheat.start();
}
private function alrt_close(evt:CloseEvent):void {
    cheat.stop();
}

private function cheatProtection(evt:TimerEvent):void {
    Alert.show("Text", "Label", Alert.OK, this, alrt_close);
}

So what I do is I call out showAlert(), but Alert (cheatProtection function) does not happen. What is wrong?

Thanks, Yan

A: 

Don't know, if this helps, but in the Adobe Flex documentation the TimerEvent listener is added after start() is called.

softcr
doesn't change anything...
Yan
+1  A: 

should be:

private var cheat:Timer;

private function init():void {
    cheat = new Timer(2000, 1);
    cheat.addEventListener(TimerEvent.TIMER_COMPLETE, cheatProtection);
    cheat.start();
}

private function showAlert():void {
    cheat.reset();
    cheat.start();
}
private function alrt_close(evt:CloseEvent):void {
    cheat.stop();
}

private function cheatProtection(evt:TimerEvent):void {
    Alert.show("Text", "Label", Alert.OK, this, alrt_close);
}
init();
Eugene
still the same, no change
Yan
try again, i've updated
Eugene
unfortunately still doesn't work
Yan
please post full your code here or at pastebin.com!!!!
Eugene
AS3: http://pastebin.com/24xj99LNMXML start: http://pastebin.com/XiPfYpWX
Yan
and what about this http://pastebin.com/PnUcrtz9 instead?
Eugene
Yes! :) how would then I be able to stop the timer? on the rollOver?
Yan
better use *cheat.stop();* instead :) and dont forget to accept answer) and rate it
Eugene
thanks, hope these helps, have a happy coding Yan! :)
Eugene