Apache flex 计时器警报-修复
我有一个计时器警报:Apache flex 计时器警报-修复,apache-flex,actionscript-3,function,timer,alert,Apache 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 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不知道这是否有帮助,但是在Adobe Flex文档中,TimerEvent侦听器是在调用start()之后添加的。应该是:
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();
您正在调用调用类中的某个地方调用init(),对吗?嗯。。我正在做:rollOut=“showart()”缺少某些内容?对,但您是否明确地在某个时候调用init()?如果没有,则永远不会创建计时器。(除非自动调用init();我创建Flex对象已经有一段时间了。)是的!:)那么我怎样才能停止计时器呢?翻车?