home *** CD-ROM | disk | FTP | other *** search
- class com.neodelight.std.Analyzer
- {
- var mc;
- var dt;
- var smoothing;
- var timestamp;
- var counted;
- var avgIntime;
- var sumIntime;
- var anadisplay;
- var timeStampStepIn;
- static var count = 0;
- function Analyzer(smoothing, mode)
- {
- this.mc = _root.createEmptyMovieClip("Analyzer" + com.neodelight.std.Analyzer.count,_root.getNextHighestDepth());
- this.mc.timestamp = getTimer();
- if(isNaN(smoothing))
- {
- smoothing = 0;
- }
- this.mc.smoothing = Math.min(1,Math.max(0,smoothing));
- this.mc.createTextField("my_txt",1,50 + com.neodelight.std.Analyzer.count * 50,0,50,20);
- com.neodelight.std.Analyzer.count = com.neodelight.std.Analyzer.count + 1;
- this.mc.my_txt.multiline = false;
- this.mc.my_txt.wordWrap = false;
- this.mc.my_txt.type = "dynamic";
- this.mc.my_txt.variable = "anadisplay";
- this.mc.my_txt.selectable = false;
- this.mc.my_txt.border = true;
- this.mc.my_txt.background = true;
- this.mc.counted = 0;
- this.mc.dt = 30;
- this.mc.avgIntime = 0;
- this.mc.sumIntime = 0;
- var _loc0_ = null;
- if((_loc0_ = mode) !== 1)
- {
- this.mc.onEnterFrame = function()
- {
- var _loc2_ = getTimer();
- this.dt = (1 - this.smoothing) * (_loc2_ - this.timestamp) + this.smoothing * this.dt;
- this.timestamp = _loc2_;
- if(!this.counted)
- {
- return undefined;
- }
- this.avgIntime = this.smoothing * this.avgIntime + (1 - this.smoothing) * this.sumIntime;
- this.sumIntime = 0;
- this.counted = 0;
- this.anadisplay = "%" + Math.round(this.avgIntime / this.dt * 100 * 10) * 0.1;
- };
- }
- else
- {
- this.mc.onEnterFrame = function()
- {
- if(!this.counted)
- {
- return undefined;
- }
- this.sumIntime /= this.counted;
- this.avgIntime = this.smoothing * this.avgIntime + (1 - this.smoothing) * this.sumIntime;
- this.sumIntime = 0;
- this.anadisplay = Math.round(this.avgIntime / this.dt * 100 * 100) * 0.01 + "X" + this.counted;
- this.counted = 0;
- };
- }
- }
- function startCount()
- {
- this.timeStampStepIn = getTimer();
- }
- function stopCount()
- {
- this.mc.sumIntime += getTimer() - this.timeStampStepIn;
- this.mc.counted = this.mc.counted + 1;
- }
- }
-