2013-10-29 1 views
-1

안녕하세요 저는 ac3으로 새롭습니다.게임 종료 후 시간 표시 as3

이 타이머에 대한 내 코드입니다 :

의이 프레임에 계속있어 게임의 끝에서 프레임 1 에서 시작 3. 내가 거기에 타이머를 표시하는 방법을 잘 모릅니다

...

var timer:Timer = new Timer(100); 
timer.start(); 
timer.addEventListener(TimerEvent.TIMER, timerTickHandler); 
var timerCount:int = 0; 
     function timerTickHandler(Event:TimerEvent):void 
    { 
timerCount += 100; 
toTimeCode(timerCount); 
    } 

    function toTimeCode(milliseconds:int) : void { 
//create a date object using the elapsed milliseconds 
var time:Date = new Date(milliseconds); 

//define minutes/seconds/mseconds 
var minutes:String = String(time.minutes); 
var seconds:String = String(time.seconds); 
var miliseconds:String = String(Math.round(time.milliseconds)/100); 

//add zero if neccecary, for example: 2:3.5 becomes 02:03.5 
minutes = (minutes.length != 2) ? '0'+minutes : minutes; 
seconds = (seconds.length != 2) ? '0'+seconds : seconds; 

//display elapsed time on in a textfield on stage 
timer_txt.text = minutes + ":" + seconds+""; 
    } 
+0

코드에 문제가있는 것 같지 않습니다. 이슈가 뭐야? – Glitcher

답변

0

타이머 기능이 원하는 것이 아닙니다. 그것은 카운트 다운을위한 것입니다. 카운트 업하기를 원할 것입니다. 시작했을 때 레코딩이 필요하며 현재 런타임에서이를 기록합니다.

import flash.utils.*; 
var start:Number = flash.utils.getTimer(); 

function showElapsedTime():void { 
    trace(toTimeCode(flash.utils.getTimer() - start)); 
}