4 Replies Latest reply on Mar 21, 2008 4:16 PM by Rich Zep

    Countdown timer

    Rich Zep Level 1
      Hi, I have made a countdown timer and after a bit of faffing aroung it works. The only problem is that it is always 60 days out (too many). Any ideas people?
        • 1. Re: Countdown timer
          _fanboy_
          You could subtract sixty from whatever number you get and display that number o.0

          Maybe I didn't understand your question, lol.
          • 2. Re: Countdown timer
            Rich Zep Level 1
            Hi Fanboy,
            I too thought of that but where do I subtract 60 hours in the code?

            Here is my code.


            var targetDate:Date = new Date(2008,05,21);
            var targetTime = targetDate.getTime();

            this.onEnterFrame = function() {

            var today:Date = new Date();
            var currentYear = today.getFullYear();
            var currentTime = today.getTime();



            var timeLeft = targetTime - currentTime;

            var sec = Math.floor(timeLeft/1000);
            var min = Math.floor(sec/60);
            var hrs = Math.floor(min/60);
            var days = Math.floor(hrs/24);

            sec = String(sec % 60);
            if (sec.length < 2) {
            sec = "0" + sec;
            }
            min = String(min % 60);
            if (min.length < 2) {
            min = "0" + min;
            }
            hrs = String(hrs % 24);
            if (hrs.length < 2) {
            hrs = "0" + hrs;
            }
            days = string(days);

            var counter:String = days + ":" + hrs + ":" + min + ":" + sec;
            time_txt.text = counter;
            }
            • 3. Re: Countdown timer
              _fanboy_ Level 1
              Instead of

              days = string(days)

              just put

              days = string(days-60)
              • 4. Re: Countdown timer
                Rich Zep Level 1
                Brilliant. Thanks for your time fanboy.