7 Replies Latest reply on Dec 22, 2015 11:02 AM by resdesign

    Trouble with a Countdown Timer

    jmflu

      So I did search on this topic and that is how I got started from this thread:

       

      Edge animate countdown

       

      I am using the sample files provided by user: dharmk

       

      So here is my project file: Dropbox - simplecountdown.zip

       

      I started with this sample, but I wanted the countdown to countdown to a specific day, so I switched the variable as suggested to:

       

      var until = new Date(Date.UTC(2015, 0, 11, 12, 6, 7));

       

      however this makes the compisition report as: Imgur: The most awesome images on the Internet

       

      What am I doing wrong here?

        • 1. Re: Trouble with a Countdown Timer
          jmflu Level 1

          I think I figured out that it has to do with I am trying to set it more than one month ahead in time.  How can I get it to say the correct amount of days (I don't really want to have a month counter)

          • 2. Re: Trouble with a Countdown Timer
            resdesign Adobe Community Professional & MVP

            You need to use this format for your target date.

             

            //Date.UTC(year, month[, day[, hour[, minute[, second[, millisecond]]]]])

             

            var until = new Date(Date.UTC(2015, 12, 25, 10, 50, 0));

            • 3. Re: Trouble with a Countdown Timer
              jmflu Level 1

              Ok I finally got it working, but now I am having a simple but weird problem.

               

              In edge, I am trying to change the color to white on the text (which I did and it shows up in Edge), but when I preview it in html the text always goes back to black.  Examples below:

               

              in edge:

              lVaTnTj.png

              in preview:

               

              wo02CYT.png

               

              Any idea why this would keep going back to black?  I could post the code of the js if that helps.

               

               

               

              //Change this as per your requirement

              var until = new Date(Date.UTC(2016, 0, 11, 0, 0, 0));

              var $dd = sym.$("dd");

              var $hh = sym.$("hh");

              var $mm = sym.$("mm");

              var $ss = sym.$("ss");

               

               

              function pad(num, size) {

                  var s = num+"";

                  while (s.length < size) s = "0" + s;

                  return s;

              }

               

               

              function startCounter() {

                updateCounter();

                setInterval(updateCounter, 1000);

              }

               

               

              function updateCounter() {

                var now = new Date();

                var delta = until - now;

               

               

                var days  = Math.floor( delta / (86400000) );

                var hours = Math.floor( delta / (3600000) );

                var mins  = Math.floor( delta / (60000) );

                var secs  = Math.floor( delta / 1000 );

               

               

                var dd = days;

                var hh = hours - days  * 24;

                var mm = mins - hours * 60;

                var ss = secs - mins  * 60;

               

               

                $dd.html(pad(dd,2));

                $hh.html(pad(hh,2));

                $mm.html(pad(mm,2));

                $ss.html(pad(ss,2));

              }

               

               

              startCounter();

              • 4. Re: Trouble with a Countdown Timer
                jbird42786

                Can anybody help with my Flash countdown issue?  Below is the script, it works but I want specific spacing between the days/hours/minutes/seconds.  Even though I set the text up with the correct spacing, the exported file doesn't carry it over and it adds the : which I don't want.

                 

                this.onEnterFrame = function() {

                 

                var today:Date = new Date();

                var currentYear = today.getFullYear();

                var currentTime = today.getTime();

                var targetDate:Date = new Date(2016,0,31);

                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;

                }

                • 5. Re: Trouble with a Countdown Timer
                  resdesign Adobe Community Professional & MVP

                  Could you ask you question in the Flash forum since you are using Flash (Animate CC) and not Edge Animate?

                  • 6. Re: Trouble with a Countdown Timer
                    jbird42786 Level 1

                    my apologies, thought I was in the Flash forum.  Thank you!

                    • 7. Re: Trouble with a Countdown Timer
                      resdesign Adobe Community Professional & MVP

                      You are the perfect example of why some of us thought that calling Flash, Animate CC would confuse people!

                       

                      Good luck on your project!