Copy link to clipboard
Copied
Hello! I'm trying to make a countdown timer with AS3 in a dynamic text box to add to my timed puzzle game. The "100" simply won't show up in the text box.
The code:
var nCount = 100;
timer_txt.text = nCount.toString();
I tried this exact same code in a new document, and it worked perfectly. However, in the file I'm editing, there's already a lot of extra (not DRY) code that I think is interferring with the timer.
I would copy paste my existing code but it's 1600+ lines and would clog up this post (happy to put the code up later if someone needed it). Any help would be appreciated!
Copy link to clipboard
Copied
is there an error message when testing?
if not, encode a trace statement that repeatedly polls your textfield's text.
Copy link to clipboard
Copied
There wasn't an error message, and the trace returned "100" so it seems to work that way...
I commented out my existing code and tried it again - I'm following a tutorial and tried this code
var nCount: Number = 100;
var myTimer: Timer = new Timer(1000, nCount);
timer_txt.text = nCount.toString():
myTimer.start();
myTimer.addEventListener(TimerEvent.TIMER, countdown);
function countdown(e: TimerEvent): void {
nCount--;
timer_txt.text = nCount.toString():
}
which returned error 1009. I tested this code in a seperate document and it worked perfectly. Not sure what's going on, I'm new to AS3.
Copy link to clipboard
Copied
Also, everything is on frame 1 so I don't understand why the function or variable (or something) can't be accessed
Copy link to clipboard
Copied
you're using colons where you should be using semi-colons. those should all be generating errors (and not 1009 errors).