子串,定时器和LED灯,as3

时间:2010-04-30 21:40:15

标签: flash actionscript-3

如何将我的计时器与LED灯同步?我不明白如何设置字符串和条件,因此它们对每个数字空间都是唯一的。

需要每个闪光灯的条件和值

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

完整代码

//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 :(得分:0)

此作品
如果else允许在不同时间触发补间。你每次都会暂停零。这需要解决这个问题,但其余的都没问题。

重新生成子串作为数字

//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");

如果没有

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
}