Posted By

imternet on 01/26/14


Tagged

timer as3 countDown


Versions (?)

Simply As3 CountDown with using Timer


 / Published in: ActionScript 3
 

URL: http://www.truckgamesxl.com

Every game coder need countdown in actionscript. i will show this snippet simple how can you make it. i am already making my own games. you can show my game and if you have got a any question you can ask me. click here for show my game.

  1. //Firstly we are creating dynamic textBox. Give it instance name "Timer"
  2.  
  3. / Create the two variables.
  4. var minute = 0;
  5. var second = 0;
  6.  
  7. // Create the timer
  8. // Checks the clock function every 1000 milisecond (1 second)
  9. var timer:Timer = new Timer(1000);
  10. timer.addEventListener(TimerEvent.TIMER, clock);
  11. timer.start();
  12.  
  13. // Function that increments the timer
  14. function clock(evt:TimerEvent):void {
  15. // every time this function is checked increment second by one
  16. second += 1;
  17. // If the second is 59
  18. if(second > 59){
  19. // The minute will be plussed with 1
  20. minute += 1;
  21. //and the zero will be set to 00
  22. second = 00;
  23. }
  24. // Displays the time in the textbox
  25. Timer.text = String("Time is: ["+minute+":"+second+"]");
  26. }

Report this snippet  

You need to login to post a comment.