15 Replies Latest reply on Apr 12, 2007 10:41 AM by kglad

    Countdown Timer Help

    Hunter2049
      Hi folks, just a quick question....I followed a tutorial to create a countdown timer through flash, and I can't get it to work. I've set up a dynamic text box named time_txt and have the following code:

      this.onEnterFrame = function() {

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

      var targetDate:Date = new Date(currentyear,1,10)
      var targetTime = targetDate.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;
      }

      However, when I press "Control + Enter" to test my timer, only the staic text on the screen is displayed. Any ideas as to what might be going wrong? If it helps at all, here's the URL for the tutorial: http://www.oman3d.com/tutorials/flash/video/countdown.php

      Thanks!