我有一个定时器警报:
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函数)并没有发生。怎么啦?
谢谢你,燕
发布于 2010-09-01 04:40:34
应该是:
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();
发布于 2010-09-01 04:21:30
不知道这是否有帮助,但在Adobe Flex文档中,TimerEvent侦听器是在调用start()之后添加的。
https://stackoverflow.com/questions/3612821
复制相似问题