Skip navigation
Currently Being Moderated

How to get this timer to run non stop....

Feb 29, 2012 1:19 PM

I have this count up timer but I need it to run non stop once I put it on a is the code....


var startT:Number = 1;

var endT:Number =8000000;

onEnterFrame = function ()


    if (startT >=endT)


        delete onEnterFrame;

        tf.text = String(endT);




        tf.text = String(startT);

        startT += 1;



  • Currently Being Moderated
    Feb 29, 2012 1:30 PM   in reply to csclark0530

    If you mean you want to be able to go back to the web site multiple times and see how far along it has continued to count, that won't happen with the approach your code shows unless you leave the file running and hang around for the 8 million counts.  Your code will always start counting at 1. 


    What you really need to have is a timer that counts relative to a starting date/time.

    Mark as:
  • Currently Being Moderated
    Feb 29, 2012 3:15 PM   in reply to csclark0530

    What you would do is select a starting date/time, preferably in the past relative to the date/time you have the file on the web.  Then you take the current date/time and subtract the starting date/time from it.  Then convert that if you need to into some numeric value.


    Just as a for instance, look into the getTime() method of the Date class.  It always returns the number of milliseconds from a particular date/time (January 1, 1970).  So you declare a start Date object using the Date constructor (see the help files) and use the getTime() method for that Date to get the starting time.  Then keep looping and creating new Date object for the current date/time and run the getTime() method for that.  Within each loop you subtract the second time from the first to get the time between them (in milliseconds) which you are free to deal with as you prefer in terms of how you convert/present it.  When the desired value has been reached you execute your    tf.text = String(endT); line.

    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points