home *** CD-ROM | disk | FTP | other *** search
- class PerformanceController
- {
- var aFrmTms;
- static var nFA = 10;
- var nLFT = 0;
- var cdl = 3;
- static var lf = 18;
- static var uf = 29;
- static var mdl = 3;
- function PerformanceController()
- {
- this.aFrmTms = [];
- this.nLFT = getTimer();
- }
- function onEnterFrame()
- {
- var _loc4_ = getTimer();
- this.aFrmTms.push(_loc4_ - this.nLFT);
- if(this.aFrmTms.length > PerformanceController.nFA)
- {
- var _loc3_ = 1000 / this.arrMean(this.aFrmTms);
- _global.root.performanceDisplay.text = "fps=" + _loc3_ + "\n" + "detailLevel=" + this.cdl;
- if(_loc3_ > PerformanceController.uf)
- {
- if(this.cdl < PerformanceController.mdl)
- {
- this.setDetailLvl(this.cdl + 1);
- }
- }
- else if(_loc3_ < PerformanceController.lf)
- {
- if(this.cdl > 1)
- {
- this.setDetailLvl(this.cdl - 1);
- }
- }
- this.aFrmTms.length = 0;
- }
- this.nLFT = _loc4_;
- }
- function arrMean(arr)
- {
- var _loc3_ = 0;
- var _loc1_ = 0;
- while(_loc1_ < arr.length)
- {
- _loc3_ += arr[_loc1_];
- _loc1_ = _loc1_ + 1;
- }
- return _loc3_ / arr.length;
- }
- function setDetailLvl(l)
- {
- switch(l)
- {
- case 1:
- _root._quality = "LOW";
- break;
- case 2:
- _root._quality = "MEDIUM";
- break;
- case 3:
- _root._quality = "HIGH";
- }
- this.cdl = l;
- }
- }
-