Need countdown timer for game

i'm making a shooting game i need a timer that counts down
and then when it gets to 0 it goes to a certain frame. This is the
code i'm using:
var seconds:Number=10;
time_txt.text="";
function countDown(){
var time=seconds--;
time_txt.text=time;
if(time=0){
gotoAndStop("lose");
clearInterval(counter);
counter=setInterval(countDown, 1000);
can any one help

just in case this might help anyone tries to help
here is the code i'm using for the game:
stop();
//Set global highScore variables
highScore = 0;
//Set the properties for the game elements
_root.lastframe = false;
//Stop bullets
//See AS for bullet MC for details
setProperty(_root.crosshair, _visible, true);
setProperty(_root.bullet, _visible, false);
//Individual destroyed target images hidden until needed
setProperty(_root.target1d, _visible, false);
setProperty(_root.target2d, _visible, false);
setProperty(_root.target3d, _visible, false);
//As above. Individual highlighted target images hidden until
needed
setProperty(_root.target1Image, _visible, false);
setProperty(_root.target2Image, _visible, false);
setProperty(_root.target3Image, _visible, false);
mouse.hide();
//hide mouse to use cross-hairs
//select a target to shoot at random then add that target
//to the array of selected targets so that it isn't used
//again in this game.
//When the number of direct hits against the selected
//target has been reached. Find another random target.
//Check whether it exists in the array. If yes, select
//again. If no, make visible.
_root.targets = new Array();
//create array on the main
//timeline so that it is
//easily accessed by all MCs
_root.targets[0] = "target1";
_root.targets[1] = "target2";
_root.targets[2] = "target3";
//3 targets we are using in
//tutorial
n = _root.targets.length;
//get length of array
ran = random(n);
//get random number location to select from array
target = _root.targets[ran];
//show random array location
_root.activeTarget = target;
//create target variable
setProperty("_root."+target+"Image", _visible, true);
//show target
_root.targets.splice(ran, 1);
//remove the random element
//from the array. splice
//the random number found and
//to the depth of one so only
//one element is removed.
var seconds:Number = 10;
time_txt.text = "";
function countDown() {
var time = seconds--;
time_txt.text = time;
if (time == -10) {
gotoAndStop("lose");
clearInterval(counter);
counter = setInterval(countDown, 1000);
any help will be appreciated
Spud

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 create timer for game?

    I want to know how much time player spend in the game.
    For this i want create a timer.
    I thing it must be something like this:
    player come to the game (time 0:00), player plaing for example 22 minutes, gameover game (player spend 22 minutes and 0 sec).
    code:
    import flash.utils.getTimer;
    var gameStartTime:uint;
    var gameTime:uint;
    var gameTimeField:TextField;
    function mainFunction():void
         gameTimeField = new TextField();
         addChild(gameTimeField);
         gameStartTime=getTimer();
         gameTime=0;
         addEventListener(Event.ENTER_FRAME,showTime);
    function showTime(event:Event)
         gameTime=getTimer()-gameStartTime;
         gameTimeField.text="You plaing: "+clockTime(gameTime)+"min";
    function clockTime(ms:int)
         var seconds:int=Math.floor(ms/1000);
         var minutes:int=Math.floor(seconds/60);
         seconds-=minutes*60;
         var timeString:String=minutes+":"+String(seconds+100).substr(1,2);
         return timeString;
    mainFunction();
    Is this correct way?
    If you know how to make code smaller can you please share?
    Maybe exist standart component or something else for this?
    Thank you.

    Thank you guys!
    Just asking how to make timer correct:)
    I thout maybe you know existing standart coder or standart component for it?
    For example i use the same timer for 5 games.. and for every game i need create code..  Is it possible to make code just one time and create something like standart components in Flash IDE ? Or maybe adobe have place where everyone can create components and share whit other? Or its all not possible, and need create the same code again?
    By the way why i dont see my secons here?:
    var gameStartTime:uint;
    var gameTime:uint;
    function mainFunction():void
         gameStartTime=getTimer();
         gameTime=0;
         addEventListener(Event.ENTER_FRAME,showTime);
    function showTime(event:Event)
         gameTime=getTimer()-gameStartTime;
         myText.text="Time: "+clockTime(gameTime);
    function clockTime(ms:int)
         var seconds:int=Math.floor(ms/1000);
         var timeString:String=String(seconds+100).substr(1,2);
    mainFunction();

  • Countdown timer for Captivate 5

    Hey! I'm trying to find two types of countdown timers. One that would display during a slide and the other that can span a few slides (i.e. you have 5 minutes to do the questions on these 3 slides). Anyone know of any widgets like this? I saw the following timer, but it seems to be for Captivate 4 - http://forums.adobe.com/click.jspa?searchID=5036774&objectType=2&objectID=2505616
    I guess for the first timer, I could simply have the user look at the countdown timer at the bottom of the screen....
    Thanks for any suggestions.

    Hello,
    I'm preparing a blog post on the default widgets that come with CP5, but lack of time... Hope to make it this week.
    Anyway there is an interesting widget 'Timer' included. You can set a maximum, let it count up or count down, put it in analog or digital mode etc.
    If you put the widget on a master slide the counter will restart for each slide. If you put it on a slide and set it to display for the rest of the project, it will continue timing. As you can hide any object on a later slide using an action or an advanced action, this is the way to go if you want a timer for a sequence of slides. I blogged about Hiding objects, here is the link:
    Playing Hide-and-Seek
    You can also create a custom timer by using the system variable cpInfoElapsedTimeMS. Tried to explain that workflow in another blog post (was for a Quiz, but is also possible for any other slide):
    Quiz slide showing elapsed time
    Lilybiri

  • Countdown Timer for Fileserv pauses when viewing other tabs, resumes when returned to tab. Is there any way to make the timer keep going?

    Hi, when I use Fileserv to download files, it has a countdown timer like many file-hosting services. However if I go view other tabs while the timer is going, it gets paused until I come back to the tab and then it resumes.
    For example, I download a file and the timer starts from 30 seconds, at the 25 second mark I view a different tab (lets say to check my email), and after about 40 seconds or so I come back to the Fileserv tab and it's just counting down from 25 seconds.
    This didn't happen before when I was on 3.6.
    Is there anyway to keep the timer going? As 30 seconds is precious enough to check an email or blog while I wait.

    Maybe it keeps working if you tear off that tab and open it in its own window.

  • Timer for game program.

    Hello all,
    I am making a game program and I need a way to implement a timer so that it the game will end if the time expires.
    Is there any easy function to help me with this task?

    Thanks for the reply and I just found that class.
    Thanks

  • An onsceen timer for game???

    Hi,
    I have to make a computer game in java3d and I'm pretty clueless, any help I could get here would be great.
    Current problem : Once the user presses a "Start" button I want a timer counting down from 5 mins. I want to timer to be on screen so the user can see it the whole time he is playing the game and when the timer is up a message appears ie GAME OVER! and the game stops running.
    Does anyone have any ideas or have done this before?? Heres some code on it I've hacked together so far.
    Thanks,
    Sean
    //create start button to start game/timer
    private Buttton go = new Button("Start");
    Panel p = new Panel( );
    p.add(go);
    add("North",p);
    go.addActionListener(this);
    go.addKeyListener(this);
    public void actionPerformed(ActionEvent e ) {
    // start timer when button is pressed
    if (e.getSource()==go){
    //if (time timer is not running) ???
    { //start timer +display timer ???
    //when timer == 0.00 add "game over" message to screen + stop game ???

    That's how you would do it in Java2D, for sure.
    If you want to put some Java2D stuff around your canvas, this kind of thing should work fine.
    If you want to incorporate it into your 3d scene (the way most games work) you will need to find a way to write it into your Java3D scene. There are a few different ways of doing this- I have had some success by writing the text into a graphic and then using the graphic I have just created as a texture on a plane attached to my viewPlatform. I believe there is something clever you can do to write it directly onto the view instead of using geometry in the scene, but I don't recall what...

  • Customize SUP Reboot countdown time for a particular collection of computers

    SCCM 2007 SP2 R3.  We deploy to a clinical environment, and while many workstations can be updated and rebooted at any time (generally our maintenance windows run from 1800 - 0600 and we have a 60-minute reboot countdown set at the Site Server on the
    agent) we have a special subset of wireless computers on roll-around medicine carts that need to be treated differently, including a 120-minute countdown.
    IS there a way to set the reboot countdown for SUP for the computers in these collections to a different time than the default, or, any way to do this outside of the Site Server controlling things via the agent?
    Thanks.

    First, note that there is no reboot countdown specific to just updates; there is just a single reboot countdown for any reboot initiated by ConfigMgr.
    I don't remember when they added it (R2 I think), but you can override this value on a collection by collection basis. Simply open the properties dialog of the desired collection and it's on one of the tabs (sorry, don't have a 2007 console in front of me
    to tell you the exact place).
    Jason | http://blog.configmgrftw.com

  • Question about countdown timer for final cut 5.1

    I know someone just asked for one in fce but is there one for 5.1. I need to count down 30 mins. for one thing and 30 sec for another. is there a good template? thanks in advance.

    Seems to me you could put a timecode generator filter in a slug over your video, then use a luma key to super it... then run it backwards ie.. -100% speed. You can crop it too so you don't have to see the frames go by, just seconds and minutes...
    Jerry

  • I need quick time for windows me

    just like it said i need quicktime for me can anyone help me

    http://www.apple.com/support/downloads/quicktime652forwindows.html

  • Firefox need long time for start, downloads everytime at starting, reset useles, safe mode works

    when starting the firefox.exe or the link, firefox need way too long till opening the window, everytime it starts it starts and cancel a download in download manager,
    in safe mode it starts normal, with addons disabled it starts normal, disable the addons else do not work reset dont work either

    You said that there was no problem in safe mode? Try this; disable
    '''ALL of your add-ons''' and '''ALL your plug-ins'''. See if there is a problem.
    If not, pick a few (two or three) items to enable. Keep going like this
    until you have the problem again.

  • Need more time for tween to finish

    How do I let this tween finish fading before doing the next thing? I'm thinking it needs a listener from the event class?
    tfDisplay.addEventListener(Event.COMLETE,myFunction); //something like this??
    var xTween:Tween = new Tween(tfDisplay, "alpha", Strong.easeIn, 1,0,1, true);
    thanks, Chop

    Thank you, it's working...
    This is what I used and seems to work. I just don't know if it is "clunky"
    or not as there seems to be a fair bit of redundency in the code:
    (where's the as code instert button on this forum?)
    contact and purchase buttons bring up a text field with text from a .txt file... want to fade in and fade out. In this example, you can go from "contact" to "purchases" or vice versa and the previous text will fade out before the current one fades in.
    function contact
    (evt:MouseEvent):void{
        var outTween:Tween = new Tween(tfDisplay, "alpha", Strong.easeIn, 1,0,1, true);
        outTween.addEventListener (TweenEvent.MOTION_FINISH,tFinishHandler);
            function tFinishHandler(evt:TweenEvent):void{
            myAlbum.alpha=0;
            setBullet(26,214);
            displayTextField ("contact.txt");
            var inTween:Tween = new Tween(tfDisplay, "alpha", Strong.easeIn, 0,1,1, true);
        function purchases
    (evt:MouseEvent):void{
        var outTween:Tween = new Tween(tfDisplay, "alpha", Strong.easeIn, 1,0,1, true);
        outTween.addEventListener (TweenEvent.MOTION_FINISH,tFinishHandler);
            function tFinishHandler(evt:TweenEvent):void{
            myAlbum.alpha=0;
            setBullet(4,186);
            displayTextField ("purchases.txt");
            var inTween:Tween = new Tween(tfDisplay, "alpha", Strong.easeIn, 0,1,1, true);
    again, things are working so I'm happy

  • Easiest way to create a countdown timer

    I need to make a countdown timer for a wedding webpage that I'm, but having trouble finding a good code for it. Anyone know a simple way to do this? don't need anything real complicated, just simple numbers that count down will work

    Hi,
    You can download the files to any location on your computer. Then open dreamweaver, open the HTML page within the downloaded files. Open in code + design view. Go back to the downloaded file outside dreamweaver. Copy the css and java script files to the respective website root folders on your computer. Open the index.html or any html page where you want the counter to appear. Now, the first html page you opened in dreamweaver which was from the downloaded file, check how the css and java script files are placed on the html page. do the same in your html page. then check how the counter information is placed inside the <body></body> tags.
    Save your work. launch the offline page on the browser and see if the counter works.
    All the best.

  • I don't remember my security answer and it's not my 1st time for using this device,i using this before..but the last time I try to buy some games using iTunes card its saying this is your 1st time using this device so I need to answer the security questio

    i don't remember my security answer and it's not my 1st time for using this device,i using this before..but the last time I try to buy some games using iTunes card its saying this is your 1st time using this device so I need to answer the security questio

    https://expresslane.apple.com/

  • 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.

Maybe you are looking for