3Sep/0910
How to create a Flash Performance Calculator in AS3
This is a simple AS3 performance calculator I created..
/*********************************************************\
|*Thanks for using Fighterlegends performance Calculator!*|
\*********************************************************/
var documentFPS = stage.frameRate;
var lastTime = getTimer();
var samples = new Array(30);
var frameCounter = 0;
stage.addEventListener(Event.ENTER_FRAME, update);
function update(event:Event) {
var currentTime = getTimer();
var timeDif = (currentTime-lastTime)/1000;
lastTime = currentTime;
var actualFPS = 1/timeDif;
samples[frameCounter % 30] = actualFPS;
frameCounter++;
var averageFPS = 0;
for (var i = 0; i < 30; i++) {
averageFPS += samples[i];
}
averageFPS /= 30;
var performance = Math.round(averageFPS/documentFPS *100);
var lag = 100-performance;
fps.text = Math.round(averageFPS) + " fps\n" + documentFPS + " target fps\n" + performance +
"% performance\n" + lag + "% lag\n";
}
Just create this dynamic box on the stage:
Instance: fps
width: 140
height: 84
Hope you give me credit!
UPDATE:
I got a new, and better update of the script from WarKry on Kongregate!

September 9th, 2009 - 08:05
Hi! I was surfing and found your blog post… nice! I love your blog.
Cheers! Sandra. R.
September 9th, 2009 - 15:56
Thanks =D
October 22nd, 2009 - 01:43
Hello from Russia!
Can I quote a post in your blog with the link to you?
October 23rd, 2009 - 13:58
Yeah! I don’t mind! I’ll check out your blog!
Hello from America!
October 28th, 2009 - 04:13
Thank’s for sharing this
This is really interesting
October 29th, 2009 - 15:51
No problem!
April 10th, 2010 - 12:12
Nice template , what is the name of tamplate you used in your site
April 10th, 2010 - 17:26
I used the Lightword template by Andrei Luca
Thanks for visiting my blog!
April 17th, 2010 - 06:18
Brilliant idea and it is duly
April 17th, 2010 - 07:32
Haha, I forgot to update this code..
I made a new one that I’m going to post possibly later today.
Thanks for visiting my thread!