home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Acao / flameout.swf / scripts / __Packages / LRG / Utils / FPSDisplay.as next >
Encoding:
Text File  |  2006-06-13  |  1.1 KB  |  41 lines

  1. class LRG.Utils.FPSDisplay extends MovieClip
  2. {
  3.    var m_fUpdatePeriod;
  4.    var m_fNumUpdates;
  5.    var m_fTotalFramesTime;
  6.    var m_fLastTime;
  7.    var m_fLastUpdateTime;
  8.    var onEnterFrame;
  9.    var m_kTimeDisplay;
  10.    function FPSDisplay()
  11.    {
  12.       super();
  13.       this.init();
  14.    }
  15.    function init()
  16.    {
  17.       this.m_fUpdatePeriod = 250;
  18.       this.m_fNumUpdates = 0;
  19.       this.m_fTotalFramesTime = 0;
  20.       this.m_fLastTime = getTimer();
  21.       this.m_fLastUpdateTime = getTimer();
  22.       this.onEnterFrame = this.updateFPS;
  23.    }
  24.    function updateFPS()
  25.    {
  26.       this.m_fNumUpdates = this.m_fNumUpdates + 1;
  27.       var _loc2_ = getTimer();
  28.       this.m_fTotalFramesTime += _loc2_ - this.m_fLastTime;
  29.       this.m_fLastTime = _loc2_;
  30.       if(_loc2_ - this.m_fLastUpdateTime > this.m_fUpdatePeriod)
  31.       {
  32.          this.m_fLastUpdateTime = _loc2_;
  33.          var _loc3_ = this.m_fTotalFramesTime / this.m_fNumUpdates;
  34.          var _loc4_ = 1000 / _loc3_;
  35.          this.m_fNumUpdates = 0;
  36.          this.m_fTotalFramesTime = 0;
  37.          this.m_kTimeDisplay.text = "fps: " + Math.floor(_loc4_);
  38.       }
  39.    }
  40. }
  41.