0
votes

I'm using Flash Pro CS6 to make an easy game where some cubes drop. I added a text field (instance name is timerText) where I wat the time to display. Here is the code:

var time:int =0;
var timer:Timer = new Timer(1000,0);

timer.start();
timer.addEventListener(TimerEvent.TIMER, cubeFall);

function cubeFall(t:TimerEvent) {

time++;
timerText.text = time.toString();

if (time == 3) {
    cube_1.play();
    }
}

My problem is that the text field, when the game starts, after 1 second the number 1 appears, but it doesn't continue. Any Ideas why?

2
looks ok although i might be missing something. the best thing to do is to put trace(time.toString()) line in the function . also you should add your event listener before timer.start() however that isn't the cause of the errorEran
I decided to remove the timer cause, besides this, it was giving me dome other errors. Thanks anyway for the support :)Zoske

2 Answers

0
votes

Your code works fine for me? (Flash CS5.5 output to Flash Plater 10.2).

Try setting the textfield font to _sans. If that works it might be due to you needing to embed the font.

0
votes
    var time:int =0;
var timer:Timer = new Timer(1000,0);

timer.addEventListener(TimerEvent.TIMER, cubeFall);
timer.start();

function cubeFall(t:TimerEvent) {

time++;
timerText.text = time.toString();

if (time == 3) {
    cube_1.play();
    }
}


//try this one you set the event and then start