actionscript display timer
- by Aaron
ok so im using real basic code for a small game and ive got a timer set up on one room and cant get it to display in the endgame room please help?
this is the code i used
var gameStartTime:uint;
var gameTime:uint;
var gameTimeField:TextField;
gameTimeField = new TextField();
gameTimeField.x = 900;
gameTimeField.y = 50;
addChild(gameTimeField);
gameStartTime = getTimer();
gameTime = 0;
addEventListener(Event.ENTER_FRAME,showTime);
function showTime(event:Event)
{gameTime = getTimer()-gameStartTime;
gameTimeField.text = "Time: "+clockTime(gameTime);
}
function clockTime(ms:int)
{
var seconds:int = Math.floor(ms/100);
var minutes:int = Math.floor(seconds/60);
seconds -= minutes*60;
var timeString:String = minutes+":"+String(seconds+100).substr(1,2);
return timeString;
}