2010-08-31 4 views
2

J'ai une alerte minuterie:alerte Timer - FIX

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

Alors ce que je fais est que j'appelle à showAlert(), mais Alert (fonction cheatProtection) ne se produit pas. Qu'est-ce qui ne va pas?

Merci, Yan

+0

Vous appelez init() quelque part dans votre classe d'appel, non? –

+0

hmm .. Je fais: rollOut = "showAlert()" quelque chose manque? – Yan

+2

Droit, mais appelez-vous explicitement init() à un moment donné? Sinon, votre minuteur ne sera jamais créé. (Sauf si init() est appelé automatiquement, cela fait un moment que j'ai créé un objet Flex.) –

Répondre

1

devrait être:

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

toujours le même, pas de changement – Yan

+0

réessayez, j'ai mis à jour – Eugene

+0

malheureusement toujours doesn ' t travail – Yan

0

Je ne sais pas, si cela aide, mais dans la documentation Adobe Flex l'auditeur TimerEvent est ajouté après le démarrage() est appelée.

+0

ne change rien ... – Yan