How can I make a Day countdown timer in flash

Here's my code, and below the code is the error message
// register function
addEventListener('enterFrame',daytimer_handler);
// calls repeatedly
function daytimer_handler(evt:Event):void{
// current date
var today:Date = new Date(2013, 4, 22);
// current Year
var currentYear = today.getFullYear(2013);
// current month
var currentMonth = today.getMonth(April);
// current day
var currentDay = today.getDate(Monday);// current time
var currentTime = today.getTime(12:00:00 PM);
// target date (5 days from now change to your need
var targetDate:Date = new Date(currentYear, currentMonth, currentDay+5);
var targetDay = targetDate.getTime(April/27/2013);
// time remaining
var timeLeft = targetDay-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);
// convert sec to string
sec = String(sec%60);
// if less than add a 0
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) {
// display day string
var dayCounter:String = days;
timer_display.text = dayCounter;
} else {
trace("Happy Birthday!");
var newTime:String = "0";
timer_display.text = newTime;
removeEventListener('enterFrame',daytimer_handler);
error message:
Description:
1084: Syntax error: expecting rightparen before colon.  
Source:
var currentTime = today.getTime(12:00:00 PM)

There are numerous syntax errors in your code, especially usage of Date methods - getFullYear, getMonth, etc. To begin with, this code should look like this:
import flash.events.Event;
// register function
addEventListener(Event.ENTER_FRAME, daytimer_handler);
// calls repeatedly
function daytimer_handler(e:Event):void
// current date
          var today:Date = new Date(2013, 4, 22);
// current Year
          var currentYear = today.getFullYear();
// current month
          var currentMonth = today.getMonth();
// current day
          var currentDay = today.getDate(); // current time
          var currentTime = today.getTime();
// target date (5 days from now change to your need
          var targetDate:Date = new Date(currentYear, currentMonth, currentDay + 5);
          var targetDay = targetDate.getTime();
// time remaining
          var timeLeft = targetDay - 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);
// convert sec to string
          sec = String(sec % 60);
// if less than add a 0
          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)
// display day string
                    var dayCounter:String = days;
                    timer_display.text = dayCounter;
          else
                    trace("Happy Birthday!");
                    var newTime:String = "0";
                    timer_display.text = newTime;
                    removeEventListener('enterFrame', daytimer_handler);

Similar Messages

  • How can i make it so every time i save something the date is included in the title?

    how can i make it so every time i save something the date is included in the title?

    More information would be helpful. Are you doing this in an application? If so, what application.

  • 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 can I make Recover_Mode Is Real Time Apply in Data Duard

    Hi Experts
    I have Primary and Standby Databases I need to know how can I change the recover mode to Real Time Apply?
    I run the following queury in Primary Site:
    SELECT RECOVERY_MODE FROM V$ARCHIVE_DEST_STATUS WHERE DEST_ID=2;
    RECOVERY_MODE
    MANAGED
    I have oracle 11g R2 / Windows Server 2008 R2!
    Logs generated and transfered successfully!

    Hello;
    Cancel recovery on the standby and then.
    SQL
    ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION;
    Note: You should have Standby redo at both the Primary and Standby sites.
    Best Regards
    mseberg

  • How can i improve this 2min countdown timer?

    Hello
    I'm trying to see if anyone has any ideas on how to improve this simple 2 minute countdown timer.  All suggestions are welcome!
    Thanks in advance!
    -noviceLabVIEWuser
    Solved!
    Go to Solution.
    Attachments:
    2min Countdown Timer.vi ‏38 KB

    As an alternative, I used a case structure to eliminate some calculations for Sample Time while Air Time is counting down and vice versa.  I don't know if this is necessarily better.  Your original code was simple and it worked fine.
    False case showing:                                          ​                                 True case showing:
    - tbob
    Inventor of the WORM Global

  • How can I make my new AirPort Time Capsule with VOIP?

    I purchased an AirPort Time Capsule because of the modem capability. The modem we have from the phone company isn't very good.
    Now I have a little problem. I forgot we have our phone over internet and I cannot figure out how to set it all up.
    Any ideas for my latest problem? I'd run back to the store/genius bar, but it's a ferry ride away and I'm not sure it would do any good to go back because all my phone "stuff" (cords, etc) wall jacks, is all here.
    Current set up is this:
    Modem box has ethernet (yellow) cable going from it to imac. It also has blue cable going from it to ATA Router (smaller black box). Each box (white larger "modem" box, and black smaller ATA Router) have a phone cord going from wall (2 separate jacks) to the box. And obviously each has it's own power cord.
    I tried moving all plugs from white modem box to AP TC, but there really isn't a phone jack on back of APTC. It clicked in place in one of the <--> ports, but I'm getting a flashing amber light on the front, and no internet connection.
    Any ideas for my latest issue?? I know so much more about computers than I ever wanted to know, but it obviously isn't enough.
    Thanks!

    I purchased an AirPort Time Capsule because of the modem capability.
    There is no modem in the airport routers.. they are all plain ethernet routers.
    It sounds like you have adsl modem.. and I would just leave it alone.
    But if you want to play and your ISP supports PPPOE and the modem allows bridging or bridge mode.. then you can bridge the modem and use TC to establish the link to the ISP.. on the internet tab use PPPOE and put in your ISP username and password.
    You can then plug the ATA into one of the LAN ports of the TC.
    Overall this is probably not a great idea.
    Exactly what modem are you talking about .. make and model from the base please?? Who is your ISP?
    What model is the ATA? Actual model numbers from it please.
    Generally you will plug the TC into the modem and use simple bridge mode.
    Even though the airport wizard might attempt to take over as main router.. please do the setup manually and choose bridge mode.
    See Airport Utility shows "unexpected error - please try again" when connecting to Time Capsule

  • How can I make the current date/time be sent when emailing as XML?

    I'm creating a form for a customer to use for submitting print jobs. This customer will be emailing the XML form data, which will in turn be converted into a production order. I'd like to make the PDF form capture my customer's system time, so that I know when they filled out the form. I COULD just leave that up up the customer and use required current date and time fields, but that provides the ability for the customer to falsify that information.
    Is there any good way to capture the current date/time in the XML data, so that the customer doesn't need to nor has the ability to?
    Any suggestions would be great!

    You can use the following methods getHours(),getMinutes(), and getSeconds() from the date object to obtain the values for hour,minute,and second.
    Click here to see an example:
    http://66.34.186.88/LiveCycleSamples/.3bbc2f4b.pdf

  • Does Firefox History display the "time" as well as the date; how can I make my history show "time" as well as date, etc.?

    I would like to check my history for time of day, as well as for the date. Is this a feature that is common? How do I set it to work showing the time, as well as, the date? Thank you.

    Thank you. I went to the Show All History library and under "View" I selected for time and date. Thank you for the link to how it is done!

  • How can I make a backup without Time Machine?

    I'm finally upgrading to Mountain Lion, but my Seagate GoFlex harddrive isn't letting me backup via time machine.  do I have to reformat the harddrive to be used with time machine?  or is there an app I can download so I can get a clean install of OS X without having to loose any of my files or apps?

    The disk for Time Machine should be firmatted as HFS+
    If you want to do a backup so that you can do an erase & install, I suggest that you make a bootable clone with either CCC or SuperDuper.
    Allan

  • How can I make the text larger in this flashing box from Old Toad?

    I'm trying to use flashing text here: http://web.me.com/phelpssculpture/Site/hands_on.html
    which I copied from OldToad's site here:http://web.me.com/toad.hall/Demo_1/Miscitems.html
    I can't figure out how to make the text larger.
    Any suggestions?
    Thanks, David

    At the end of the code, you can find
    document.write('You can add Blinking Text!');
    insert a "size" attribute to "font" tag (eg. size="10")
    document.write('You can add Blinking Text!');

  • How can I make a 3D cube using only Flash CS4?

    Looking for a tutorial on how to make a 3d cube. The best one I found was how to make a book, which is three sides short of a cube. If worse comes to worse I think there's a way to take two identical movie clips with three sides each and pivot them around the same point to form a cube. But if there's some solid instruction anyone could provide or a link, it would save me countless hours of guessing testing and revising.
    Thanks!

    Hi,
    Wire in '448' to the 'New Permissions' of the Access Rights VI. This will set the file as readable, writable and executable. I just tried this (on WinNT, though).
    The 'permissions' parameter is a 16-bit integer where the least 9 bits are used. Of these, for Windows, bits 8, 9, and 10 (0-indexed) are important (i.e. if these are set = integer 448). See online Help for full details.
    Hope this helps,
    Khalid

  • How can i make an interactive page book in Flash?

    I would like to know how to make an interactive sort of book
    in flash sorta similar to the one
    here and i want to
    turn it into a website, would anyone have any ideas at all of how i
    would go about this, all information would be helpful.
    Or Similar to this one
    http://www.templatemonster.com/flash-templates/12695.html
    Thanks In Advance
    Raph

    Raphael Essoo-Snowdon wrote:
    > anyone? know how to edit it PLEASE :D
    >
    > thank you in advance
    Open the library CTRL L and look for folder call
    "PageElements"
    You will find there movie clips call page1 page2 page3 page4
    etc...
    Every page is a movie clips so whatever you import from PS
    will
    need to be converted to movie clip. Name it page"number"
    according
    to your order and do not forget to give it LINKAGE name.
    To linkage clip you need to right click it while in library,
    go to
    LINKAGE than check the box EXPORT FOR ACTION SCRIPT and type
    the
    page name same as the library name (example) "page88"
    Now, on timeline you have layer call ACTIONS and on 5th frame
    of that
    layer is the place where you add pages using action script
    once all
    the library stuff is in order. You will find there :
    addPage("start");
    addPage("page1");
    addPage("page2");
    addPage("page3");
    addPage("page4");
    addPage("page5");
    Just add as much as you need.... Pretty much it
    Best Regards
    Urami
    !!!!!!! Merry Christmas !!!!!!!
    Happy New Year
    <urami>
    If you want to mail me - DO NOT LAUGH AT MY ADDRESS
    </urami>

  • How can i make my printer respond faster to the print comand?

    I have an hp officejet 6500A.   It is very slow in responding to the print command.  How can I make it take less time then 30 seconds to a minute to respond?

    OK, restart your router.   Actually if your adsl2z is a bridge, what is the router?
    Say thanks by clicking "Kudos" "thumbs up" in the post that helped you.
    I am employed by HP

  • How can I make my Apple TV more reliable? It takes a day to download a HD movie on a T1 to play later, but when I try to play the movies, Apple TV can't, and says try again later. Doesn't the day download time put the HD movie on the Apple TV device?

    How can I make my Apple TV work? I downloaded two movies, to play later, on April 4, 2014. I tried to watch them this evening only to get a message they are not available and to try later. How long can it take Apple to download the movies? I encourage anyone thinking about buying an Apple TV to get a different media player that is reliable. Apple TV is not worth the money, nor the time it takes to download movies, nor the effort trying to get your money back when Apple TV fails,and it failsl oftern.. Apple never seems to have a problem charging for the movies, but it frequently has a provlem delivering what people pay for.

    Welcome to the Apple Community.
    Try the following steps, check whether things are working after each step where appropriate, before trying the next.
    Restart the Apple TV (Settings > General > Restart).
    Restart the Apple TV by removing ALL the cables for 30 seconds.
    Restart your router.
    Reset the Apple TV (Settings > General > Reset > Reset all settings)
    Restore the Apple TV (Settings > General > Reset > Restore)

  • How can I make a weekly 'to do' list?  I don't want the list associated with a particular date and time; just a list of things to get done!

    How can I make a weekly 'to do' list? I don't want it associated with a particular day or or time, just the week, preferably with the ability to check off or remove when done.

    Thank you for the excellent reference Peddi. I had played with the OAMessageChoiceBean component yesterday, but I was able to tell from your instructions that "Picklist Display Attribute" and "Picklist Value Attribute" really are not for binding to the database EO. That was the key piece of information that had me confused.
    In addition to adding the messageChoice component to the page, I needed to write some code to synchronize the picklist value with the corresponding code value, which I placed in am OAFormValueBean (hidden form field) which I could then bind to my application's database EO in the controller, running in the processFormRequest procedure:
    /** Synchronize the catalog code with the selected catalog name */
    protected void syncCatalogValues(OAPageContext pageContext,
    OAWebBean webBean, MyApplicationAMImpl am) {   
    OAMessageChoiceBean mcb =
    (OAMessageChoiceBean) webBean.findChildRecursive("CatalogName");
    OAFormValueBean cc =
    (OAFormValueBean) webBean.findChildRecursive("CatalogCode");
    String catalogDescription = mcb.getText(pageContext);
    if (catalogDescription != null) {
    String catalogCode = am.getCatalogCode(catalogDescription);
    cc.setValue(pageContext, catalogCode);
    Along with a little code to get the catalogCode value from the LOVVO, that's all it took.
    Thanks again. This was a great help.
    Pete

Maybe you are looking for

  • Unable to Open Project from a Networked computer

    Hi All We have just recently installed Robohelp V6 on a computer in the office and after making sure that RoboSource is connected and visible, I have come to my desktop machine and made sure that 1. I could connect to the Robohelp "Server" 2. that I

  • BEX WAD 7.0:  Chart Takes Long Time to Display in Portal - Query runs FAST

    I have a BEx WAD 7.0 template which contains 3 column charts (each with it's own seperate DataProvider/Query).  When the page loads...two of the charts show up right away, but one of them takes almost a minute to display on the screen (I thought it w

  • Not using the index

    hi all, DB version is 10.2.0.4 Have a query as below SQL> explain plan for SELECT GS.LOT_NO , GS.LOT_ID , ILI.ITEM_ID ITEM_ID,   2               GR.RESULT_VALUE_CHAR QUALITATIVE_VALUE , ITM.ITEM_NO FROM              GMD_QC_TESTS GQT, GMD_RESULTS GR,

  • Help converting old Freehand files

    I have several old Freehand files, to be honest I don't remember the versions, but they were definitely before 9. I'm on a PowerMac running Freehand MX and Illustrator CS3 and do not have the Classic 9 operating system still on this machine. Am I com

  • CANON EOS 6D Moire

    Halo, i have been using Canon 60D for videomaking with great success and ease. Upgraded to 6D, using same custom picture style ( sharpness 0, contrast -4, saturation -2, color tone 0 ) to prevent moire, but cant get rid off it. Happens especially wit