タイマーのサンプル


/ Published in: ActionScript 3
Save to your folder(s)

ユーティリティにしたら便利かな


Copy this code and paste it in your HTML
  1. private var _timer:Timer = null;
  2. private function wait(sec:int):void{
  3. stopWaitTimer();
  4. _timer = new Timer(sec * 1000);
  5. _timer.addEventListener(TimerEvent.TIMER, onWaitTimer);
  6. _timer.start();
  7. }
  8.  
  9. private function stopWaitTimer(){
  10. if(_timer ! = null){
  11. _timer.removeEventListener(TimerEvent.TIMER, onWaitTimer);
  12. _timer.stop();
  13. _timer.reset();
  14. _timer = null;
  15. }
  16. }
  17.  
  18. private function onWaitTimer():void{
  19. stopWaitTimer();
  20. /* */
  21. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.