Countdown woes

Hello all,

I made a flash game in September for a university project, except it turned out to be more of an engine test than a fully functional game. So finally got some free time since then and the games something I want to re-visit and actually finish.

The game works on round based levels, each round lasts 30 seconds. In the old version the only visual communication of time left to the player was a movie clip of numbers changing every second, triggered 5 seconds before the round would end.

This was quite frankly rubbish, so now I want to add in a dynamic text field counting down from 30. I have had no experience of text fields so I’m just going off what flash help has to offer and my limited knowledge of action script…and its failing me as usual!

This is my first attempt at getting the text field to dynamically count down.

var startTime        :Number;
var countDownTime    :Number;

setInterval(timer, 1000);

function timer(){
    
    startTime = 30;
    countDownTime = startTime - 1;
    
    if(countDownTime < 0){
        trace("yay");
    }
}

timer_txt.text = countDownTime;

Would really appreciate a nudge in the right direction, I’m more concerned with what I’m doing right and wrong than actual working code.

After all I’ve got to learn sometime. :beam:

Any help would be greatly appreciated.

Thanks in advance

Signy

Edit

Whoops posted in the wrong forum, any chance of getting the thread moved to game/ai programming please.