views:

80

answers:

0

How do I trigger the animation in sync with my timer?
My timer and flip animation work, but they are out of sync with each other. I'm lost with the IF ELSE statements. Each time the value of my textfield changes, my number needs to flip. See example.

Example

//IF ELSE FUNCTION
function theFlip(event:TimerEvent):void
{
count++;
if (count < 9)
{
oldcount = count - 1;
}
else 
{
count++;
fcount=int(count)
}
}
//Cont...

alt text


Complete Code
here's the file

//Timer
var timer:Timer = new Timer(100);
//Integer values
var count:int = 0;
var fcount:int = 0; 
var oldcount:int = 0;
//Formatting String
function formatCount(i:int):String { 
var fraction:int = i % 100; 
var whole:int = i / 100;  
return ("00" + whole).substr(-2, 2) + "." + (fraction < 10 ? "0" + fraction : fraction); 
} 
//Start the timer
timer.start();
timer.addEventListener(TimerEvent.TIMER, theFlip);
//IF ELSE FUNCTION
function theFlip(event:TimerEvent):void
{
count++;
if (count < 9)
{
oldcount = count - 1;
}
else 
{
count++;
fcount=int(count)
count++;
}
var toText:String = formatCount(fcount);
sec4.digit.text = toText.substr(4, 1);
flip4.flip.digit.text = toText.substr(4, 1);
flip4.gotoAndPlay(2);
sec3.digit.text = toText.substr(3, 1);
flip3.flip.digit.text = toText.substr(3, 1);
flip3.gotoAndPlay(2);
sec1.digit.text = toText.substr(1, 1);
flip1.flip.digit.text = toText.substr(1, 1);
flip1.gotoAndPlay(2);
}