修改
我正在尝试倒数计时器。我需要当前计数值。我想到达功能之外
import flash.utils.Timer;
import flash.events.TimerEvent;
import flash.events.Event;
var count:int = 10;
var myTimer:Timer = new Timer(1000,count);
var ev:TimerEvent = new TimerEvent(TimerEvent.TIMER);
myTimer.dispatchEvent(ev);
myTimer.addEventListener(TimerEvent.TIMER, countdown);
myTimer.start();
var number1:int;
var number2:int;
mytxt.addEventListener(Event.CHANGE,rest);
function countdown(event:TimerEvent):void
{
number1 = count - myTimer.currentCount;
slr(number1);
}
function slr(s:int)
{
if (s>5)
{
mytxt.restrict = "a";
trace("a");
}
if (s<5)
{
mytxt.restrict = "b";
trace("b");
}
}
function rest(evt:Event)
{
if (mytxt.text == "a")
{
mytxt.restrict = "";
}
else if (mytxt.text=="b")
{
mytxt.restrict = "";
}
}
我想在前5秒内只按一次“按键”。并且只有一次“b”键按下第二个5秒
答案 0 :(得分:0)
目前number2
将立即设置。这是我认为你正在寻找的更多信息:
//set this under your myTimer.addEventListener(TimerEvent.TIMER, countdown);
myTimer.addEventListener(TimerEvent.TIMER_COMPLETE, onTimerComplete);
然后添加此功能:
function onTimerComplete( e:TimerEvent ):void {
number2 = number1;
trace("number2 :"+number2);
}