Turn your Mobile Apps into m-commerce apps – Learn More!
 

Code Snippets

  

ActionScript Source Code


You're Browsing As A Guest! Register Now...
Become an Expert!

Join 414,937 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 2,674 people online right now.Registration is fast and FREE... Join Now!




Countdown Timer

good for Games! or whatever :D Written by senocular (senocular.com). Original can be found at http://www.kirupa.com/developer/actionscript/setinterval2.htm

Submitted By: reyco1
Actions:
Rating:
Views: 84,270

Language: ActionScript

Last Modified: December 31, 2006
Instructions: make a dynamic text feild and give it a variable name of: displayTime. Place the code on the first frame of the movie.

Snippet


  1. // Author: senocular.com
  2. // http://www.kirupa.com/developer/actionscript/setinterval2.htm
  3.  
  4. displayTime = 10;
  5. countDown = function () {
  6.      displayTime--;
  7.      if (displayTime == 0) {
  8.           clearInterval(timer);
  9.      }
  10. };
  11. timer = setInterval(countDown, 1000);

Copy & Paste


Comments

hoho501 2009-01-12 09:00:18

how can you make it so when you click a button it starts to count down and then not start again after you click it a second time

salientknight 2009-03-05 08:14:11

This code is close, but you forgot that you have to address a dynamic textbox using .text.. to get this code to work try this: tm=10; displayTime.text = tm; countDown = function () { tm--; displayTime.text=tm; if (tm==0) { clearInterval(timer); } }; timer = setInterval(countDown, 1000);

dhiraj141 2010-05-11 09:32:47


Add comment


You must be registered and logged on to </dream.in.code> to leave comments.