作者:愤然尔立_980 | 来源:互联网 | 2023-05-18 02:20
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.
如何将我的计时器与LED灯同步?我不明白如何设置字符串和条件,因此它们对每个数字空间都是唯一的。
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
替代文字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 个解决方案
0
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.
这有效如果else允许在不同时间触发补间。你每次都会暂停零。这需要解决这个问题,但其余的都可以。
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
}