所以PrayPrayer.position
以毫秒爲單位。您的minutes
行被1000除以得到秒,然後除以60以從秒到分鐘。您的seconds
線正在查看其餘部分。
你在hours
行開始的行使用%
,所以會看看其餘部分 - 你在那裏使用秒。 %
是模運算符。它給你了整數除法的其餘部分。所以,你的行
var seconds:uint = Math.floor(PrayPrayer.position/1000) % 60;
是找到秒(PrayPrayer.position/1000)的數量,這可能是一些大的像2337,60分,只是保持剩餘部分。 2337/60 = 38剩餘57,因此2337%60將是57.
找到小時的簡單方法是對分鐘使用相同的技巧。
var minutes:uint = Math.floor(PrayPrayer.position/1000/60);
var seconds:uint = Math.floor(PrayPrayer.position/1000) % 60;
var hours:uint = Math.floor(minutes/60);
minutes %= 60; // same as minutes = minutes % 60. Forces minutes to be between 0 and 59.