Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 11-08-2009
Member
 
Join Date: Aug 2009
Posts: 7
Flash countdown timer tutorial

Hi,

I need to create a countdown timer in Flash to view it on a web page.
I am looking for an article or a tutorial to show the countdown timer in flash. I hope someone will help me with this.

Thanks in advance.
Reply With Quote
  #2  
Old 11-08-2009
Member
 
Join Date: Apr 2008
Posts: 22
Re: Flash countdown timer tutorial

Flash simple timer / countdown

On the left we have a timer, on the right a countdown.

Let's see how to do it.

First, I created two dynamic text items, the one on the left instanced as count and the one on the right instanced as count_down.

Then, in the first frame there is this simple actionscript:

Code:
ACTIONSCRIPT:


      start_time = getTimer();

      countdown = 7200000;

      onEnterFrame = function () {

          elapsed_time = getTimer()-start_time;

          _root.count.text = time_to_string(elapsed_time);

          _root.count_down.text = time_to_string(_root.countdown-elapsed_time);

      };

      function time_to_string(time_to_convert) {

          elapsed_hours = Math.floor(time_to_convert/3600000);

          remaining = time_to_convert-(elapsed_hours*3600000);

          elapsed_minutes = Math.floor(remaining/60000);

          remaining = remaining-(elapsed_minutes*60000);

          elapsed_seconds = Math.floor(remaining/1000);

          remaining = remaining-(elapsed_seconds*1000);

          elapsed_fs = Math.floor(remaining/10);

          if (elapsed_hours<10) {

              hours = "0"+elapsed_hours.toString();

          } else {

              hours = elapsed_hours.toString();

          }

          if (elapsed_minutes<10) {

              minutes = "0"+elapsed_minutes.toString();

          } else {

              minutes = elapsed_minutes.toString();

          }

          if (elapsed_seconds<10) {

              seconds = "0"+elapsed_seconds.toString();

          } else {

              seconds = elapsed_seconds.toString();

          }

          if (elapsed_fs<10) {

              hundredths = "0"+elapsed_fs.toString();

          } else {

              hundredths = elapsed_fs.toString();

          }

          return hours+":"+minutes+":"+seconds+":"+hundredths;

      }
Line 1: Initialize the variable start_time with the current time value

Line 2: Initialize the variable countdown with the amount of milliseconds I want to start the countdown. In this case, since an hour has 3600 seconds or 3600000 milliseconds, the countdown will start from 2 hours

Line 3: Function to be executed at every frame

Line 4: Calculate the difference between the actual time and the start_time value. This is actually the elapsed time.

Lines 5-6: count and count_down text values are updated with the result of a the function time_to_string (a function I created). count will be the elapsed time, while count_down will be the difference from the countdown variable and the elapsed time. Please note that every time explained here is intended to be in milliseconds.

Let's examine the main function:

Line 9: Calculate elapsed hours dividing the time to convert (function's argument) by 3600000, the number of milliseconds in an hour

Line 10: Calculate remaining time without the elapsed hours

Lines 11-12: Some thing with the minutes, dividing the remaining time by 60000, the number of milliseconds in a minute

In the same way I calculate the seconds and the 1/100 of seconds. Lines from 16 to 35 just format the string showing the time.
Reply With Quote
  #3  
Old 11-08-2009
Member
 
Join Date: Apr 2008
Posts: 21
Re: Flash countdown timer tutorial

Creating a Countdown Timer in Flash

I think this video tutorial would help you better.
Reply With Quote
  #4  
Old 11-08-2009
Member
 
Join Date: May 2008
Posts: 33
Re: Flash countdown timer tutorial

Here is a tutorial you will find much more helpful

Date Countdown Timer

Here you will learn to create a countdown timer which counts down from the current date and time to a specific date and time in the future. This example will use days, hours, minutes, seconds and even milliseconds retrieved from Flash's Date object to calculate that countdown. But, not only will you learn what is needed to calculate that countdown; you will also learn how to incorporate custom images to represent your numbers in that countdown.

Two parts to this tutorial:

1. First there's making the graphics, which doesn't seem that difficult (though there's some tricks in helping with that.)

2. Then there's the coding to make it all work, which actually has some tricks of its own as well.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Flash countdown timer tutorial"
Thread Thread Starter Forum Replies Last Post
Need FPS display and timer countdown gadget for my windows 7 system Baanbhatt Customize Desktop 3 02-07-2012 04:08 PM
How to create countdown timer in Excel Rao's Windows Software 1 07-01-2012 12:23 PM
Getting error when trying to open a flash video tutorial from a trusted site Loafer Technology & Internet 4 05-02-2011 11:17 PM
Refresh with the help of countdown timer Sheravat Software Development 5 08-09-2010 10:01 PM
Countdown timer john83 Software Development 4 25-08-2010 09:10 PM


All times are GMT +5.5. The time now is 07:22 AM.