9 Replies Latest reply on Oct 20, 2006 5:26 PM by kglad

    need actionscrip for a count up timer

    adamski007 Level 1
      hi folks,

      i was hoping someone could point me in the right direction. i need actionscrip for a timer that will count time, days, months, and years from a certain date and time in the past. any imput will be appreciated.

      adam
        • 1. Re: need actionscrip for a count up timer
          kglad Adobe Community Professional & MVP
          the date class has all the methods you need. for example, if you want to count up from November 2, 1999 at 11:44 am you could use:

          • 2. Re: need actionscrip for a count up timer
            adamski007 Level 1
            hi kglad,

            thanks for taking the time butthis code doesn't seem to work in my project. i'm looking for a complete scrip which i can paste in a type frame. this is the coundown scrip that was in it before, i'll looking to count up from a past date.

            now = new Date();
            euro = new Date(2007, 12, 01, 00, 00, 00);
            days = (euro-now)/1000/60/60/24;
            daysRound = Math.floor(days);
            hours = (euro-now)/1000/60/60-(24*daysRound);
            hoursRound = Math.floor(hours);
            minutes = (euro-now)/1000/60-(24*60*daysRound)-(60*hoursRound);
            minutesRound = Math.floor(minutes);
            seconds = (euro-now)/1000-(24*60*60*daysRound)-(60*60*hoursRound)-(60*minutesRound);
            secondsRound = Math.round(seconds);
            if (secondsRound == 1) {
            sec = " second ";
            } else {
            sec = " seconds ";
            }
            if (minutesRound == 1) {
            min = " minute ";
            } else {
            min = " minutes ";
            }
            if (hoursRound == 1) {
            hr = " hour ";
            } else {
            hr = " hours ";
            }
            if (daysRound == 1) {
            dy = " day ";
            } else {
            dy = " days ";
            }
            timeRemaining = daysRound+dy+hoursRound+hr+minutesRound+min+secondsRound+sec;

            • 3. Re: need actionscrip for a count up timer
              kglad Adobe Community Professional & MVP
              the code i gave is complete. just attach it to a frame that plays once.

              and replace the trace() function with whatever you want for your display.
              • 4. Re: need actionscrip for a count up timer
                adamski007 Level 1
                kglad,

                -"replace the trace() function with whatever you want for your display."-

                i'm not sure what that statement means. i'm very new to action scripting and forgive me but need little more clarification.
                the date i will be starting the count from is - 3:00pm 3rd october 2006 and will be displaying it in a text box.

                thanks adam

                • 5. Re: need actionscrip for a count up timer
                  kglad Adobe Community Professional & MVP
                  if your textfield has instance name timeRemaining try:

                  • 6. Re: need actionscrip for a count up timer
                    adamski007 Level 1
                    kglad,

                    i don't know what to say but i'm still having problems figuring this thing out. it most likely has to do with my lack of knowledge on the subject. here's a link to my file that i'm working with and if you get a chance please have a look at it. right now it has the coundown code in it. (i'm trying to change that)

                    http://idisk.mac.com/adamski007-Public/clock.fla

                    warm regards,

                    adam
                    • 7. Re: need actionscrip for a count up timer
                      adamski007 Level 1
                      sorry try this link:

                      http://idisk.mac.com/adamski007-Public/?view=web

                      the file is called clock.fla

                      adam
                      • 8. Re: need actionscrip for a count up timer
                        adamski007 Level 1
                        hello,

                        i don't mean to reply to myself but i got the problem solved by combining both actionscripts and making a couple of changes. thanks for the help. here's what i came up with:

                        oldDate = new Date(2006,8,26,15,00); // september 26

                        now = new Date(); // today

                        elapsed = newDate - oldDate; // elapsed milliseconds

                        // some sample information
                        days = (now-oldDate)/1000/60/60/24;
                        daysRound = Math.floor(days);
                        hours = (now-oldDate)/1000/60/60-(24*daysRound);
                        hoursRound = Math.floor(hours);
                        minutes = (now-oldDate)/1000/60-(24*60*daysRound)-(60*hoursRound);
                        minutesRound = Math.floor(minutes);
                        seconds = (now-oldDate)/1000-(24*60*60*daysRound)-(60*60*hoursRound)-(60*minutesRound);
                        secondsRound = Math.round(seconds);
                        if (secondsRound == 1) {
                        sec = " second ";
                        } else {
                        sec = " seconds ";
                        }
                        if (minutesRound == 1) {
                        min = " minute ";
                        } else {
                        min = " minutes ";
                        }
                        if (hoursRound == 1) {
                        hr = " hour ";
                        } else {
                        hr = " hours ";
                        }
                        if (daysRound == 1) {
                        dy = " day ";
                        } else {
                        dy = " days ";
                        }
                        timeSince = daysRound+dy+hoursRound+hr+minutesRound+min+secondsRound+sec;
                        • 9. Re: need actionscrip for a count up timer
                          kglad Adobe Community Professional & MVP
                          you're welcome.