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();

Similar Messages

  • Get error message that skype has problem loading when computer is turned on the first time every day. this started when the latest firefox v6.0 was downloaded.

    get error message that skype has problem loading when computer is turned on the first time every day. this started when the latest firefox v6.0 was downloaded.

    ''mbratlie [[#question-1055011|said]]''
    <blockquote>
    It was working fine and I had no problems, and then one day I tried opening a window and it froze. When I tried quiting the program my whole window went black. The x to the close the window doesn't work. The only option I have in my tool bar is Firefox and nothing happens when I try to quit firefox. Every time I try to shut down my computer Firefox prevents it. I haven't updated Firefox yet, so it's an older program, but only by a month or two. What's going on and how do I fix it?
    </blockquote>
    This is the first time it's ever happened. I downloaded the new operating system for Firefox but I can't install it until the Firefox currently running on my laptop quits, which it won't.

  • I'm getting an "Error Code: 16" every time I try to start up the program. Any recommendations?

    Everytime I try to run the program, a pop-up always comes up telling me to uninstall and reinstall the product and the there is a "Error: 16" or something like that.  Then, when I try to download it again, it doesn't work. Help?

    Configuration error 16 | CC, CS

  • HT4437 how may I add files to time capsule apart from backup files?

    how may I add files to time capsule apart from backup files?
    I'm able to perform backup (time machine). May I add pictures, texts, movies...?
    Thanks

    not sure if this is a spc. appletv question or if you posted it in the wrong forum but there is no way
    for an appletv to access files directly from an time capsule it can only! access a shared lib from itunes from a computer running and running itunes

  • How can i add my outlook email to my ipad without useing the Exchange Service?

    Please help me in this, How can i add my outlook email to my ipad without useing the Exchange Service?

    I'm afraid you've posted in the wrong place. This is a technical forum around a particular product called 'SharePoint'. This does talk to Exchange and Outlook in places but we don't specialised in either of those. You should have a look for one of the
    generic Outlook support forums or contact your IT department if it's a work related account.

  • How do you add a new thumbnail to a slide show when using in-browser editing?

    how do you add a new thumbnail to a slide show when using in-browser editing?

    At this moment you can’t add pictures to a slideshow. You only can replace them.

  • HT201317 How do I add existing photos and albumns on my iPhone to the photo stream?

    How do I add existing photos and albumns on my iPhone to the photo stream?

    Welcome to the Apple Community.
    The easiest method is to connect your device to iTunes, transfer the photos to your computer and add them to photostream from there. If you only have a few photos to add, you could take a screenshot of each one.

  • How to disconnect internet connection in Time Capsule and reconnect without restarting the whole device?

    Hi, I would be very grateful if someone could tell me how to disconnect internet connection in Time Capsule and reconnect without restarting the whole device?
    The thing is that as I have a dynamic IP address, everytime I restart the internet connection my IP address changes. I sometimes need it to change, so I need to restart the connection. I don't know another way to restart the connection than restarting the whole Time Capsule.
    Thanks!!
    PD: the computer I use is Windows based, using the Airport Utility for Windows, but I also have a MacBook Pro I could use and an iPhone too.

    The utility in windows is very like Mac so the screenshots are from Mac as I don't have windows available now.
    How this works depends on the setup of the TC.. which you did not tell us.. you cannot change anything if you do not have the TC as the main router in the network.
    So on the internet tab you need to share a public IP address.
    On the next tab where you set IP address.
    Click the renew IP address.
    It might work.. and it might not.. the problem is you are not disconnecting the network.. sometimes the hard disconnection is required before the address will renew..
    What about unplugging the WAN port.. then click renew the IP which will fail.. then plug the wan back in again.
    In the end it is easier and faster to power cycle the TC.

  • How do I add a link for a file that can be downloaded

    I'm sure that there's a very simple answer to this, and I
    can't believe that I don't know it.
    How can I add a link to a file that will then be dowloaded by
    the user?
    Thanks

    Zip the file. Link to it. Upload it.
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.dreamweavermx-templates.com
    - Template Triage!
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    http://www.macromedia.com/support/search/
    - Macromedia (MM) Technotes
    ==================
    "Si Fi" <[email protected]> wrote in message
    news:e73jd6$i3m$[email protected]..
    > I'm sure that there's a very simple answer to this, and
    I can't believe
    > that I don't know it.
    >
    > How can I add a link to a file that will then be
    dowloaded by the user?
    >
    > Thanks

  • How can I add an event to my calendar that occurs every third day...I have an ipad.

    How can I add an event to my calendar that occurs every third day?

    Do you happen to have a Mac?  If so, and if you use iCloud to sync your calendars, you can do that on your Mac and your iPad will understand.  But you cannot create such a repitition (or something like the third Tuesday of each month) on your iPad.
    In Calendar on your Mac, you would create the event, choose "Custom ..." as the repitition frequency, then choose "Days" and choose every 3 days.

  • Every time I add a light to a scene in After Effects the program freezes

    This just started happening?? Please help
    Every time I add a light to a scene in After Effects the program freezes

    What is your After Effects version number? You said you're running "CS6", so the version number should start with 11. The latest version of CS6 is 11.0.4 - do you have that? (The latest version of AE is 13.2.0.49, in case anyone was wondering).
    Do you have your comp set to standard renderer or ray-traced?
    What are your computer specs?
    Also, what Rick and Bogiesan asked.

  • How To Directly Add Attachments to E-Business Suite Entities Without Using The Managed Attachments Window

    How To Directly Add Attachments to E-Business Suite Entities Without Using The Managed Attachments Window? any option?

    user11016624 wrote:
    How To Directly Add Attachments to E-Business Suite Entities Without Using The Managed Attachments Window? any option?
    Please see:
    http://www.oraclebusinessapps.com/2008/04/28/load-pdf-file-attachment-using-api/
    http://www.oracleerpappsguide.com/2011/04/attachment-in-oracle-application.html
    http://etrm.oracle.com/pls/et1211d9/etrm_pnav.show_object?c_name=FND_ATTACHED_DOCUMENTS_PKG&c_owner=APPS&c_type=PACKAGE
    Thanks,
    Hussein

  • How do i move music from my mac to my iphone when the "add to" option does not appear?

    How do I add transfer music from my mac to iphone with the new itunes.  The tutorial shows a "add to" icon in the upper right corner while displaying your phone content, but I do not have that option.

    It works on mine try restarting itunes and computer to see if that helps.
    If it does not then try the other way
    Click on device name in left hand sidebar. Select Music Button at the top of the page on the left and choose what Playlists, Albums, Artists and Genres you want. Click Apply

  • When I open Firefox I have to try several times because a Runtime Error with the program C:\Windows\System32\regsvr32.exe

    when I open Firefox I have to try several times because a Runtime Error with the program C:\Windows\System32\regsvr32.exe

    '''Try the Firefox Safe Mode''' to see how it works there. The Safe Mode is a troubleshooting mode, which disables most add-ons.''
    ''(If you're not using it, switch to the Default theme.)''
    * You can open the Firefox 4.0+ Safe Mode by holding the '''Shift''' key when you use the Firefox desktop or Start menu shortcut.
    * Or use the Help menu item and click on the '''Restart with Add-ons Disabled...''' menu item while Firefox is running.
    ''Don't select anything right now, just use "Continue in Safe Mode."''
    ''To exit the Firefox Safe Mode, just close Firefox and wait a few seconds before using the Firefox shortcut (without the Shift key) to open it again.''
    '''''If it is good in the Firefox Safe Mode''''', your problem is probably caused by an extension, and you need to figure out which one.
    Please follow the [[Troubleshooting extensions and themes]] article for that.
    ''When you figure out what's causing your issues, please let us know. It might help other users who have the same problem.''

  • How do you "pause" an open application, like Mac automatically does when the memory is full?

    How do you "pause" an open application, like Mac automatically does when the memory is full?
    I would like to do so proactively when I am not using a certain program but need to keep it open, and I want to free up computer resources.
    In other words, I want to keep a given program open, but stop it from "thinking".

    There is an application that I can only open a set number of times before it expires.  Every time the program closes, you get one less use out of it.  I want to use it as long as possible, so I thought I would just keep it open all the time.  However, it consistently turns on the fan on the computer, so I imagine it uses a lot of resources.  I got the idea after the Force Quit program "paused" it once after getting overloaded with all the apps I had open.  It stopped the fan, and I was able to open it and run it again later with no problems.  The tricky thing with trying to intentionally overload the system is that it's a hit or miss on which open program the OS will pause (to my knowledge).

Maybe you are looking for