0
votes

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 http://www.ashcraftband.com/myspace/videodnd/logic.jpg

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;
}
}

1
Once again not quite sure what you're getting at here; your digit blinks, but your little dot doesn't? Your blink object is having its visible property set to the opposite of whatever it was before each time your timer object fires, so I assume after some unit of time passes your dot disappears, then after another unit of time it reappears, and so on. Is this what you want for the numbers as well? Also, what's the deal with you setting the condition variable to 5, then immediately checking if it's 5? You might as well remove the whole bit, it'll always return true? Explain more.debu
I was having a simple casting problem. The !visible is just wanted to create a boolean to test my code, and I'll probably use a tween instead. ParseInt got the strings back to numbers, and used if else conditions to set the LED objects. The decimals are in sync with the numbers, but the one is incorrectly firing. See my answer.anon255058

1 Answers

0
votes

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
}