home *** CD-ROM | disk | FTP | other *** search
/ Champak 48 / cdrom_image.iso / Games / breakawish.swf / scripts / __Packages / Library / Utils / Timer.as < prev    next >
Encoding:
Text File  |  2007-09-28  |  1.2 KB  |  57 lines

  1. class Library.Utils.Timer
  2. {
  3.    var nTimeSpent;
  4.    var nMethod;
  5.    var nFrameRate;
  6.    var bTimerActive;
  7.    static var TIMER_COUNT_UP = 1;
  8.    static var TIMER_COUNT_DOWN = -1;
  9.    static var BASE_FRAMERATE = 30;
  10.    function Timer()
  11.    {
  12.       this.nTimeSpent = 0;
  13.       this.nMethod = Library.Utils.Timer.TIMER_COUNT_UP;
  14.       this.nFrameRate = Library.Utils.Timer.BASE_FRAMERATE;
  15.       this.bTimerActive = false;
  16.    }
  17.    function doEnterFrame()
  18.    {
  19.       if(this.bTimerActive)
  20.       {
  21.          this.nTimeSpent += this.nMethod;
  22.       }
  23.    }
  24.    function doStartTimer()
  25.    {
  26.       this.bTimerActive = true;
  27.    }
  28.    function doStopTimer()
  29.    {
  30.       this.bTimerActive = false;
  31.    }
  32.    function setTime(__nTime)
  33.    {
  34.       this.nTimeSpent = __nTime * (this.nFrameRate / 1000);
  35.    }
  36.    function doResetTime()
  37.    {
  38.       this.nTimeSpent = 0;
  39.    }
  40.    function get Time()
  41.    {
  42.       return Math.round(this.nTimeSpent / (this.nFrameRate / 1000));
  43.    }
  44.    function get Frames()
  45.    {
  46.       return this.nTimeSpent;
  47.    }
  48.    function set Method(__n)
  49.    {
  50.       this.nMethod = __n;
  51.    }
  52.    function set FrameRate(__n)
  53.    {
  54.       this.nFrameRate = __n;
  55.    }
  56. }
  57.