0
我的櫃檯倒數了,而不是倒數?我喜歡它從10分鐘倒計時,當小時爲0,分鐘爲0和秒爲0我希望它刪除計數器,它應該去gotoAndStop(2)的另一幀。我的櫃檯倒數而不是倒數
var countdownTimer:Timer = new Timer(1000);
countdownTimer.addEventListener(TimerEvent.TIMER, updateTime);
countdownTimer.start();
var startTime:int = getTimer();
function updateTime(e:TimerEvent):void
{
// milliseconds passed
var timePassed:int = getTimer()-startTime;
var seconds:Number = Math.floor(timePassed/1000);
var minutes:Number = Math.floor(seconds/60);
var hours:Number = Math.floor(minutes/60);
seconds %= 60;
minutes %= 60;
hours %= 24;
var sec:String = seconds.toString();
var min:String = minutes.toString();
var hrs:String = hours.toString();
if (sec.length < 2) {
sec = "0" + sec;
}
//A zero will automatic be put to the right side og 1, so "1" will be "10"
if (min.length < 2) {
min = "1" + min;
}
if (hrs.length < 2) {
hrs = "0" + hrs;
}
var time:String = hrs + ":" + min + ":" + sec;
time_txt.text = time;
https://stackoverflow.com/questions/22141106/as-3-flash-countdown-timer-for-game-over-screen –
@EastonBornemeier感謝您的回覆,但在該線程的答案沒」對我來說沒有任何意義。 – cop77
因爲您顯示** getTimer() - startTime **。變量** startTime **是固定的。函數** getTimer()**返回自應用程序啓動後的值(以毫秒爲單位),這意味着每次調用它時結果等於或大於上次結果。因此,** getTimer() - startTime **上升。總是。 – Organis