actionscript display timer

Posted by Aaron on Stack Overflow See other posts from Stack Overflow or by Aaron
Published on 2010-06-03T10:57:31Z Indexed on 2010/06/03 11:04 UTC
Read the original article Hit count: 254

Filed under:
|

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;
}

© Stack Overflow or respective owner

Related posts about actionscript-3

Related posts about timer