home *** CD-ROM | disk | FTP | other *** search
- class LRG.Utils.FPSDisplay extends MovieClip
- {
- var m_fUpdatePeriod;
- var m_fNumUpdates;
- var m_fTotalFramesTime;
- var m_fLastTime;
- var m_fLastUpdateTime;
- var onEnterFrame;
- var m_kTimeDisplay;
- function FPSDisplay()
- {
- super();
- this.init();
- }
- function init()
- {
- this.m_fUpdatePeriod = 250;
- this.m_fNumUpdates = 0;
- this.m_fTotalFramesTime = 0;
- this.m_fLastTime = getTimer();
- this.m_fLastUpdateTime = getTimer();
- this.onEnterFrame = this.updateFPS;
- }
- function updateFPS()
- {
- this.m_fNumUpdates = this.m_fNumUpdates + 1;
- var _loc2_ = getTimer();
- this.m_fTotalFramesTime += _loc2_ - this.m_fLastTime;
- this.m_fLastTime = _loc2_;
- if(_loc2_ - this.m_fLastUpdateTime > this.m_fUpdatePeriod)
- {
- this.m_fLastUpdateTime = _loc2_;
- var _loc3_ = this.m_fTotalFramesTime / this.m_fNumUpdates;
- var _loc4_ = 1000 / _loc3_;
- this.m_fNumUpdates = 0;
- this.m_fTotalFramesTime = 0;
- this.m_kTimeDisplay.text = "fps: " + Math.floor(_loc4_);
- }
- }
- }
-