更新时间:2023-10-26 19:16:10
getTimer() 将返回一个整数,表示从 Flash 启动开始的确切毫秒数.
getTimer() will return an int of exactly how many milliseconds from when flash started.
import flash.utils.getTimer;
var myInt:int = getTimer() * 0.001;
myInt 现在将是程序运行了多少秒.
myInt will now be however many seconds the program has been running.
哦要知道它已经运行了多长时间,只需保留初始 myInt 并根据当前计时器检查它.
edit: oh to tell how long it has been running just keep the initial myInt and check it against the current timer.
所以当游戏第一次开始时.
so when the game first starts.
var startTime:int = getTimer();
然后是每一帧或任何你需要检查的时候.
then every frame or whenever you need to check it.
var currentTime:int = getTimer();
var timeRunning:int = (currentTime - startTime) * 0.001; // this is how many seconds the game has been running.