home *** CD-ROM | disk | FTP | other *** search
- class Library.Utils.Timer
- {
- var nTimeSpent;
- var nMethod;
- var nFrameRate;
- var bTimerActive;
- static var TIMER_COUNT_UP = 1;
- static var TIMER_COUNT_DOWN = -1;
- static var BASE_FRAMERATE = 30;
- function Timer()
- {
- this.nTimeSpent = 0;
- this.nMethod = Library.Utils.Timer.TIMER_COUNT_UP;
- this.nFrameRate = Library.Utils.Timer.BASE_FRAMERATE;
- this.bTimerActive = false;
- }
- function doEnterFrame()
- {
- if(this.bTimerActive)
- {
- this.nTimeSpent += this.nMethod;
- }
- }
- function doStartTimer()
- {
- this.bTimerActive = true;
- }
- function doStopTimer()
- {
- this.bTimerActive = false;
- }
- function setTime(__nTime)
- {
- this.nTimeSpent = __nTime * (this.nFrameRate / 1000);
- }
- function doResetTime()
- {
- this.nTimeSpent = 0;
- }
- function get Time()
- {
- return Math.round(this.nTimeSpent / (this.nFrameRate / 1000));
- }
- function get Frames()
- {
- return this.nTimeSpent;
- }
- function set Method(__n)
- {
- this.nMethod = __n;
- }
- function set FrameRate(__n)
- {
- this.nFrameRate = __n;
- }
- }
-