定时器提醒 - FIX

时间:2010-08-31 20:11:10

标签: flex actionscript-3 function 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);
}

所以我做的是调用showAlert(),但不会发生Alert(cheatProtection函数)。有什么问题?

谢谢,Yan

2 个答案:

答案 0 :(得分:1)

应该是:

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();

答案 1 :(得分:0)

不知道,如果这有帮助,但在Adobe Flex文档中,调用start()后会添加TimerEvent侦听器。