Countdown Timer

Can anyone gve me any advice on how to make a countdown timer
in actionscript 3?
I have tried several ways and have so far been
unsucessful.

Here's something simple:
var endDate:Date = new Date(2012, 11, 21);
var t:Timer = new Timer(500);
t.addEventListener(TimerEvent.TIMER, msLeft);
t.start();
function msLeft(e:TimerEvent){
var now:Date = new Date();
var ms = endDate.valueOf() - now.valueOf();
var secs = Math.floor((ms / 1000) % 60);
var mins = Math.floor((ms / 1000 / 60) % 60);
var hours = Math.floor((ms / 1000 / 60 / 60) % 24);
var days = Math.floor((ms / 1000 / 60 / 60 / 24) % 365);
var years = Math.floor(ms / 1000 / 60 / 60 / 24 / 365);
trace(years, "years", days, "days", hours, "hours", mins,
"minutes", secs,
"seconds");
Dave -
www.offroadfire.com
Head Developer
http://www.blurredistinction.com
Adobe Community Expert
http://www.adobe.com/communities/experts/

Similar Messages

  • Best way to implement a countdown timer for a turn based LCCS game

    Hello,
    I am trying to build a turn based game and sketching out the high level map, so I can focus my efforts towards the direction I should be digging.
    One thing I have not seen much in the sample apps is how a turn based game is best handled.
    For example, a countdown timer. Should it be a shared property? Or a Baton which is supposed to manage workflows and has a timeout property?
    Or, should I forget those two, and time this on the server, although if it would become popular keeping track of all the times in the rooms would cost an arm and leg. Would love to hear some best practices on this.

    good idea.
    Which one or all of them?
    Once you eliminate the impossible, whatever remains, no matter how improbable, must be the truth. - "Sherlock holmes" "speak softly and carry a big stick" - theodore roosevelt. Fear leads to anger, anger leads to hate, hate leads to
    suffering - Yoda. Blog - http://www.computerprofessions.co.nr

  • How can I make a countdown timer using After Effects

    I'd like to make a video that has a timer that counts down one second at a time. I need one starting at 5:00 (five minutes). Is there a way to easily do this in After Effects without having to manually change the text every second?
    Thanks.

    I'm glad that you found a solution, but I thought that you might appreciate a suggestion of another approach.
    Colin Braley provides a tutorial and example project on
    his website that show how to use an expression on the Source Text property to animate text to overcome some of the limitations of the Numbers effect.
    There's a similar example in the
    "Example: Animate text as a timecode display" section of After Effects Help.
    Here are some Community Help searches that can lead you to some ideas, too:
    Community Help search for 'countdown timer'
    Community Help search for 'digital countdown timer'

  • Countdown Timer Error Msg: "Warning: 1090: Migration issue"

    Hey folks,
    New to Flash here (using CS3), trying to create a countdown
    timer.
    Following is the error message I receive when trying to test
    the
    movie:
    "Warning: 1090: Migration issue: The onEnterFrame is not
    triggered
    automatically by Flash Player at run time in ActionScript
    3.0. You
    must first register this handler for the event using
    addEventListener
    ( 'enterFrame', callback_handler).
    Does anyone know what this means? And please "dumb it down"
    for this newbie. :)
    Following is the actionscript I'm using:
    this.onEnterFrame = function() {
    var today:Date = new Date();
    var currentYear = today.getFullYear();
    var currentTime = today.getTime();
    var targetDate:Date = new Date(2007,5,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;
    Thanks in advance!!!

    It just means that you can't do things the "old" way. You
    have to use the
    AS3 event model, like so:
    this.addEventListener("enterFrame", enterFrameHandler);
    function enterFrameHandler(evt:Event) {
    var today:Date = new Date();
    var currentYear = today.getFullYear();
    var currentTime = today.getTime();
    var targetDate:Date = new Date(2007,5,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;

  • Javascript countdown timer not working in Safari

    Years ago I copied a Javascript for a countdown timer and it has been working on my website ever since in both Safari and Firefox. I have been working on updating my site and suddenly it stopped working in Safari, but still works in Firefox. Obviously, I'd like it to work in everyone's browser if possible. I've created a page which only has the countdown timer on it. Can anyone tell me what I need to do to get it to work in Safari?
    The test page where you can see this is: http://hyperflite.com/countdowntest.html
    TIA

    Hi,
    Is there any reason for the numerous body tags in there?
    <pre><body onload="doCountdown();">
    <body>
    <body ... >
    </pre>
    I don't have Safari here to test with, but I wouldn't have thought they were helping matters

  • 5 minute countdown timer with 3d extrusion  for AE CC  5:00

    dear  AE  Family,
    Total Newbie here  looking to make a 3d countdown timer in  after effects  CC.  I know how to use the effect  to make the standard timer.  But I want to make the
    3d extrusion  5:00 which looks much better.  My CC came with  cinema 4d  lite but cant seem to put them together. 
    PS  I really need it to look like  5:00  4:59,   to 0:00 . 3d extrusion.
    Thanks in advance, much appreciated.

    Have you gone though Getting Started with After Effects?
    Have you seen the Basic Workflow series?
    Be aware that if you want extruded text with Ray-traced rendering you are going to be in for long render times even with a compatible Cuda card installed and extremely long render times without one.
    The easiest way to make a countdown timer that will work with extruded text is to Google Countdown Timer After Effects and then look for expressions. You will find this popular universal timer expression from Dan Ebberts: Dan Ebberts's Expressioneering Design Guide
    Get that far and get back to us with your problems.
    BTW, there are other ways to mimic 3D extrusions and simple layer effects like Bevel and Emboss or the effect Bevel Alpha that may meet your design idea.

  • How can I create an animated countdown timer?

    Is there a way to create an animated countdown timer in Adobe Fireworks (animated gif)?
    Thank you

    In the Edit workspace, place the images you want to appear in each frame of the animation on separate layers of the Layers panel. For example, to create an animation of an eye blinking, you would place an image of the open eye on one layer, and an image of the closed eye on another layer.
    Choose File > Save for Web.Note: If your image has multiple layers, you can also open the Save For Web dialog box from the Save As dialog box by choosing CompuServe GIF Format and selecting Layers As Frames.
    Optimize the image in GIF format.
    Select Animate.
    Set additional options in the Animation section of the dialog box:
    Loop Continuously repeats the animation in a web browser.
    Frame Delay Specifies the number of seconds that each frame is displayed in a web browser. Use a decimal value to specify fractions of a second. For example, use .5 to specify half a second.

  • How to implement countdown timer in apex

    Hi all,
    I want to implement timer in my application.i am working on apex 4.0 version.I am developing online test application,so for this i want to display timer for test.
    can anyone suggest me how can i implement countdown timer in my application.
    thanks
    jitu

    Hi,
    You can refer "Martin Giffy D'Souza's" Enhanced APEX Session Timeouts example
    http://www.talkapex.com/2009/09/enhanced-apex-session-timeouts.html
    Regards,
    Kartik Patel
    http://patelkartik.blogspot.com/
    http://apex.oracle.com/pls/apex/f?p=9904351712:1

  • How to develop a countdown timer in jsp

    Hi all, please i have an online test application that works but i want to include a countdown timer that redirects to another page when the time runs out. please, how do i go about it. please help

    Thanks, but thats not the one i need. i want the one that will show the time in hh:mm:ss and then automatically take the user to the result page when the time i up. i have a javascript code i used but the problem is in the Result.jsp page, there are some parameters that are suppose to be passed but i dont know how to do it. this is the code:
    <form name="frm2" method="post">
    <script language="javascript">
    var sec = 10;   // set the seconds
    var min = 00;   // set the minutes
    var targetURL="result.jsp"; //the url
    var email=this.Field('email').value;
    function countDown() {
      sec--;
      if (sec == -01) {
        sec = 59;
        min = min - 1;
      } else {
       min = min;
    if (sec<=9) { sec = "0" + sec; }
      time = (min<=9 ? "0" + min : min) + " min and " + sec + " sec ";
    if (document.getElementById) { theTime.innerHTML = time; }
      SD=window.setTimeout("countDown();", 1000);
    if (min == '00' && sec == '00') { sec = "00"; window.clearTimeout(SD);
    window.location=targetURL;
    function addLoadEvent(func) {
      var oldonload = window.onload;
      if (typeof window.onload != 'function') {
        window.onload = func;
      } else {
        window.onload = function() {
          if (oldonload) {
            oldonload();
          func();
    addLoadEvent(function() {
      countDown();
    </script>
    <table width="100%">
    <tr><b><td width="100%" align="center"><span id="theTime" class="timeClass"></span></td></b></tr>
    </table>
    </form>and this is are the fields needed in the Result.jsp page..
    <input type="hidden" name="email" value=<%=exno%> />
    <input type="hidden" name="dbase" value=<%=names%> />
    <input type="hidden" name="tamt" value=<%=total%> />

  • How do i add a countdown timer in as3 that starts when the program begins?

    I also want it to remove everything that is on the stage when it reaches 0 and produce a Game Over screen.

    import flash.events.TimerEvent;
    import flash.utils.Timer;
    var countdown:Timer = new Timer (1000,TARGET_TIME);
    //after 60 Seconds every DisplayObject will be removed from stage
    const TARGET_TIME:int = 60;
    countdown.addEventListener(TimerEvent.TIMER, tick);
    countdown.addEventListener(TimerEvent.TIMER_COMPLETE, gameOver);
    function tick(e:TimerEvent):void {
        //this will count upwards 1.2.3.4....
        trace(e.currentTarget.currentCount);
    function gameOver(e:TimerEvent):void {
        // this function will remove all DisplayObjects from your Stage
        // starting from the top
        //It will not remove shapes or anything the user might have drawn on the stage
        //just things that are accessible to ActionScript (Sprites, MovieClips)
        for (var i:int = this.numChildren-1 ; i >= 0; i--) {
            removeChildAt(i);
    //countdown will start only if you call it explicitly
    countdown.start();

  • How to create countdown timer with sound

    Any ideas on how to create a minute and seconds countdown timer that would play a sound and then redirect you to another page?

    Hi,
    There is no out of the box solution to do so in Muse at the moment. If you can get your own code, you can add it to your site using "Insert HTML" feature.
    Regards,
    Aish

  • Need help on countdown timer!

    Could someone please guide me in the direction as to how to make a countdown timer?  I created a timer that counts down to a certain date, but I just want the timer to countdown 24 hours, not to a certain date.  I also want to have a button below the timer so that when you click it, it adds 30 seconds to the timer.  Can anyone help me with this?

    Hi,
    I hope it will be use full for u....
    var timelong=2000;
    var mytimer:Timer=new Timer(timelong,1);
    mytimer.addEventListener(TimerEvent.TIMER_COMPLETE,myfunc);
    mytimer.start();
    function myfunc(event:TimerEvent)
        trace("hi it's working");
    mybut.addEventListener(MouseEvent.CLICK,addtime);
    function addtime(event:MouseEvent)
        timelong+=3000;
    Thanks,
    K Swamy Vishnubhatla,

  • Countdown timer to NEXT WHOLE HOUR..?

    Hello.
    I need to create a countdown timer function.
    Normally that would not be a problem for me, but this timer needs to countdown to the next whole hour. As an example, if the time is 23:42 the countdown would say 17:35 (17 minutes, 35 seconds).
    When the timer hits zero, it will start from 59:59 and so on.. Always counting to the next whole hour.
    Im kind of in a jam and need this done ASAP, any help would be greatly apreciated!
    / Rasmus

    Im sorry if i implied that im a great actionscripter, im not
    What i would normally do is just grab a counter script from a google search and modify it to countdown to the correct time, but i havent been able to find a counter that counts down to the next whole hour.
    It should just be plain and simple and display the time in minutes and seconds like this: 25:14
    I found this one on google, counting down for christmas. If that could be modded into showing only minutes and seconds and of course counting down to the next whole hour, that would be awsome!
    https://dl.dropbox.com/u/2628604/countdown-test.fla

  • Insert a countdown timer in Keynote?

    Hello all,
    I'm sure this is an included feature that I just can't find somehow. I would like to insert a countdown timer into a slide. This seems pretty common; I've seen it done a lot. But I just can't find the Insert>timer link, or anything like it. And the iWork help file is forever searching and never going anywhere (second, embedded problem), so I can't search there.
    I tried the iPresentee thing, but it didn't download properly. Plus, it seems like a basic feature available for a presenter, especially since there's a timer included in the Presenter view.
    Any help would be appreciated. Thanks.

    d moon,
    Keynote does not provide any countdown timer features. You need to seek third parties for them.
    The iPresentee timers are a good start - their website provides a free "goodie" of timers in the form of a Keynote File where many choices of timers are available. Try downloading the file again or contact iPresentee for assistance.
    Each Timer is actually a Quicktime video clip. You select the one with the closest time range to your needs, copy it to your presentation and adjust the start point.
    Keynote > Inspector > Quicktime > Start & Stop controls

  • Possible to insert a countdown timer into an iMovie clip?

    I'm making an exercise video, and I want to insert an occasional small clip with a countdown timer.  Ideally, it would be some beautiful nature footage (like waterfalls or wildlife), with a countdown timer in the corner.
    Does anydbody know how to insert a countdown timer into an iMovie clip?
    For that matter, does anybody know where I could find/purchase 2 minutes of nature footage?

    Sure you can. What you need to do is add the initial image to the topic then create an image map. This allows you to define shapes that when the user's mouse hovers over it indicates that there is a hyperlinkto another topic. Just right click on the image, select Insert Image Map and go from there.
      The RoboColum(n)
      @robocolumn
      Colum McAndrew

Maybe you are looking for

  • How to store the output of a analog to digital converter into an 2D array

    Hi I am doing my M.Tech Thesis in Image reconstruction and I am using labview for simulation and I want to know how to store the output of a analog to digital converter into an 2D labview array.

  • Ipod will not turn off, no longer recognized

    iPod asked to update to latest software.  Upload failed and ipod left in state where it will not turn off, and is no longer recognized in itunes or as a device.

  • Conversion from ascii to 16 bit inteeger number

    Hi, I recieve data from message based measurement device via a serial port. I have used VISA functions write, read and so on. So I have read a string of charaters (8 bits). My problem is, that in this output message are text messages in char and 16 b

  • Problem in structure mapping

    hello friends, I am adding 4 fields to std program RFITEMAR this is for customer line item. iam fetching this 4 fiedls from bset table. i have copied the std structure into zstructure. and the same iam giving in my prog but iam gettting a dump saying

  • Hpe 150 freezes. hp assistants says Smart Drive error. Common issue?

    HPE-150f seems like the hard drive is going out. Is this common with these TB drives? Which do i use to replace it? After only one year? Wow. How do i reinstall? I have no CD?