views:

89

answers:

1

How would I sync my timer with my LED lights? I don't understand how to to set up the strings and conditions, so that they are unique to each number space.

Need a condition and values for each blinker

var condition:Number = 5;
if(condition==5){
blink.visible = !blink.visible;
//blink_.visible = !box.visible;
//blink__.visible = !box.visible;
}
}

alt text

Complete code

//MY 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 TIMER
timer.start();
timer.addEventListener(TimerEvent.TIMER, condition);
//ANIMATION
function condition(event:TimerEvent):void{
count++;
fcount=int(count)
var toText:String = formatCount(fcount);
dec.text = toText.substr(4, 1);
decimal.text = toText.substr(3, 1);
ones.text = toText.substr(1, 1);
//LED LIGHTS
var condition:Number = 5;
if(condition==5){
blink.visible = !blink.visible;
//blink_.visible = !box.visible;
//blink__.visible = !box.visible;
}
}

A: 

This works
If else allows triggering tweens at different times. You'll there's a pause at zero every time. This needs to fix this, but the rest is ok.

Recast substrings as numbers

//RECASTING THE STRINGS
var subThing:String = toText.substr(4, 1);
var numberThing:Number = parseInt(subThing);
trace(numberThing + " dec");
var subThing_:String = toText.substr(3, 1);
var numberThing_:Number = parseInt(subThing_);
trace(numberThing_ + " decimal");
var subThing__:String = toText.substr(1, 1);
var numberThing__:Number = parseInt(subThing__);
trace(numberThing__ + " ones");

If Else

import fl.transitions.Tween;
import fl.transitions.easing.*;
//LED LIGHTS
if(numberThing> 0){
numberThing++;
var AlphaTween:Tween = new Tween(blink, "alpha", Strong.easeOut, 0, 2, 3, true);//0,1,1
}
else if (numberThing_> 0){
numberThing_++;
var AlphaTween_:Tween = new Tween(blink_, "alpha", Strong.easeOut, 0, 2, 3, true);//0,1,1
}
else if (numberThing__> 0){
numberThing__++;
var AlphaTween_:Tween = new Tween(blink__, "alpha", Strong.easeOut, 0, 2, 3, true);//0,1,1
}

VideoDnd