home *** CD-ROM | disk | FTP | other *** search
- class com.neodelight.std.FpsCounter
- {
- var mc;
- var timestamp;
- var fps;
- var smoothing;
- var display;
- function FpsCounter(smoothing, x, y)
- {
- if(x == undefined)
- {
- x = 0;
- }
- if(y == undefined)
- {
- y = 0;
- }
- this.mc = _root.createEmptyMovieClip("fpsCounter",_root.getNextHighestDepth());
- this.mc.timestamp = getTimer();
- if(isNaN(smoothing))
- {
- smoothing = 0.9;
- }
- this.mc.smoothing = Math.min(1,Math.max(0,smoothing));
- this.mc.createTextField("my_txt",1,x,y,30,20);
- this.mc.my_txt.multiline = false;
- this.mc.my_txt.wordWrap = false;
- this.mc.my_txt.type = "dynamic";
- this.mc.my_txt.variable = "display";
- this.mc.my_txt.selectable = false;
- this.mc.my_txt.border = true;
- this.mc.my_txt.background = true;
- this.mc.onEnterFrame = function()
- {
- var _loc2_ = getTimer();
- var _loc3_ = 1000 / (_loc2_ - this.timestamp);
- if(isNaN(this.fps))
- {
- this.fps = _loc3_;
- }
- else
- {
- this.fps = (1 - this.smoothing) * _loc3_ + this.smoothing * this.fps;
- }
- this.display = Math.round(this.fps * 10) * 0.1;
- this.timestamp = _loc2_;
- };
- }
- }
-