# How to i make a countdown timer for a game

**URL:** <https://forum.kirupa.com/t/how-to-i-make-a-countdown-timer-for-a-game/286240>\
**Category:** Uncategorized\
**Created:** [April 12, 2009, 3:45pm UTC](https://forum.kirupa.com/t/how-to-i-make-a-countdown-timer-for-a-game/286240 "2009-04-12T15:45:06Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![gillygillybee](https://avatars.discourse-cdn.com/v4/letter/g/da6949/32.png) [@gillygillybee](https://forum.kirupa.com/u/gillygillybee)\
**Post date:** [April 12, 2009, 3:45pm UTC](https://forum.kirupa.com/t/how-to-i-make-a-countdown-timer-for-a-game/286240/1 "2009-04-12T15:45:06Z")

</div>

How do you create a countdown timer on an animated game, so that when the time gets to 0 and depending on your score it ttakes you to a losing page or a winning page.

This is my code so far.

I want the timing to be 60 seconds and if the score is

stop();

var score:Number=0;

addEventListener(Event.ENTER\_FRAME,testHit);  
function testHit(e:Event){  
if (kissBoy.hitTestObject(kissGirl)){  
trace(“Hit”);  
score+=5;  
scoreDisplay.text=“score:”+score  
}  
}

function runalltime(evt:Event):void{  
if (kissBoy.hitTestPoint(kissGirl.x,kissGirl.y,true)) {  
kissGirl.x=Math.random()\*400;  
kissGirl.y=Math.random()\*300;  
}

}

function keydetect(evt:KeyboardEvent):void{  
if(evt.keyCode==Keyboard.RIGHT){  
kissBoy.x+=10;  
}

if(evt.keyCode==Keyboard.LEFT){  
kissBoy.x-=10;  
}

if(evt.keyCode==Keyboard.UP){  
kissBoy.y-=10;  
}

if(evt.keyCode==Keyboard.DOWN){  
kissBoy.y+=10;  
}  
}

stage.addEventListener(Event.ENTER\_FRAME,runalltim e);  
stage.addEventListener(KeyboardEvent.KEY\_DOWN,keyd etect);

The other two frames are called gameWin and gameLose, so depending on the score within the 60 second countdown, how would i make it go to there frames and how would i make the time show up on the page.
