8 Replies Latest reply on Apr 2, 2016 1:32 PM by hpmarco1

    Count down clock Flash CS6

    griffij76

      Hi there I have created a Countdown clock in Flash CS6 the code will run but nothing seems to happen the clock does not start to count down can anyone please help: I have been at it for days and it is driving me insane

       

       

       

      Code is below

       

      this.onEnterFrame = function()

      {

      var today:Date = new Date();

      var currentYear = today.getFullYear();

      var currentTime = today.getTime();

      var targetDate:Date = new Date(2016,7,25);

      var targetTime = targetDate.getTime();

      var timeLeft = targetTime - currentTime;

      var sec = Math.floor(timeLeft/1000);

      var min = Math.floor(sec/60);

      var hours = Math.floor(min/60);

      var days = Math.floor(hours/24);

      sec = String(sec % 60);

      if(sec.length < 2){

        sec = "0" + sec;

      }

      min = String(min % 60);

      if(min.length < 2){

        min = "0" + min;

      }

      hours = String(hours % 24);

      if(hours.length < 2){

        hours = "0" + hours;

      }

      days = String(days);

      if(timeLeft > 0 ){

        var counter:String = days + ":" + hours + ":" + min + ":" + sec;

        time_txt.text = counter;

      }else{

        trace("TIME'S UP");

              var newTime:String = "00:00:00:00";

              time_txt.text = newTime;

              delete (this.onEnterFrame);

      }

      }

       

       

      Thanks Joel