How can I use variables to set my timer? I want to control delay and repeat as variable. My output acts as if there is nothing set in the timer.
Not working variables
var timer:Timer = new Timer(delay,repeat);
var delay:uint = 100;
var repeat:uint = 60;
开发者_开发技巧
Works Fine no variables
var timer:Timer = new Timer(1000,60);
Complete Unexpected results. Counts to thousands within seconds.
var timer:Timer = new Timer(delay, repeat);
var delay:uint = 1000;
var repeat:uint = 60;
timer.addEventListener(TimerEvent.TIMER, countdown);
function countdown(event:TimerEvent) {
myText.text = String(0 + timer.currentCount);
trace(0 + timer.currentCount);
}
timer.start();
I think it is because you are declaring your variables after you create your timer instance. try...
var delay:uint = 1000;
var repeat:uint = 60;
var timer:Timer = new Timer(delay, repeat);
精彩评论