set countdown correctly, as3

Posted by VideoDnd on Stack Overflow See other posts from Stack Overflow or by VideoDnd
Published on 2010-04-20T15:28:22Z Indexed on 2010/04/20 15:33 UTC
Read the original article Hit count: 134

Filed under:
|

How can I set my countdown correctly?

I'm counting from 33,000.00 to zero. It works in a fashion, but the minus operator appears in the textfield.

//Countdown from 33,000.00 to zero
var timer:Timer = new Timer(10);  
var count:int = -3300000; 
var fcount:int = 0; 
timer.addEventListener(TimerEvent.TIMER, incrementCounter);  
timer.start();   
function incrementCounter(event:TimerEvent) {  
count++;  
fcount=int(count);
mytext.text = formatCount(fcount);
}
function formatCount(i:int):String { 
var fraction:int = i % 100; 
var whole:int = i / 100;  
return ("0000000" + whole).substr(-7, 7) + "." + (fraction < 10 ? "0" + fraction : fraction); 
} 

alt text


EXAMPLE
I need something I can update with XML, to be an up-counter or down-counter depending on the variables.

//Count up from 33,000.00
var countValue:int = 3300000;
count = countValue;

//Count down from 33,000.00
var countValue:int = -3300000;
count = countValue;

© Stack Overflow or respective owner

Related posts about flash

Related posts about actionscript-3