onSelfEvent (load)
{
var start : String = "02:00";
result.text = start;
_global.min = int(start.slice(0,2));
_global.sec = int(start.slice(3,5));
var timerInterval : Number;
var not_active : Boolean = true;
var keyListener : Object = new Object();
keyListener.onKeyDown = function() //on key down
{
if (not_active) //check if countdown not_active onkeypress , if true = start/resume
{
if (Key.isDown(32)) //keypress
{
//trace("active");
timerInterval = setInterval(counter, 1000);
not_active = false;
}
}
else //pause
{
//trace("pause");
clearInterval(timerInterval);
not_active = true;
}
}
Key.addListener(keyListener); //register the listener with the Key object so that it can receive notification from the key down and key up events.
}
function counter() : void
{
//trace("min = " add min);
//trace("sec = " add sec);
//trace("typeof min = " add typeof min add " typeof sec = " add typeof sec)
if(sec == 0)
{
if(min == 0) //if sec = 0 and min = 0
{
clearInterval(timerInterval); //clearintervam
}
else //if sec = 0 and min != 0
{
sec = 59;
min --; // min = min - 1
}
}
else
{
sec --; //sec = sec - 1
}
result.text = zero_check(min) add ":" add zero_check(sec); //less than 10 add a 0 to number
}
function zero_check(check : int)
{
if(check < 10)
{
check = "0" add check; //add a 0
}
return(check);
}
onSelfEvent (load){
clock=Math.floor(getTimer()/100)/10;
/* if (seconds==0) {
seconds=600;
minute--
}
if (x!=clock) {
seconds--
}*/
x=clock;
if (var ==00 && var ==59) {
result.textColor = 0xFF9900;
}}
我希望我的倒数计时器在达到59秒时变为橙色,在达到30秒时变为红色但是它不起作用我现在不知道为什么,我正在研究Swish我不知道它用于编写脚本的语言。