I thought I should share a component I whipped together for ActionScript 3 projects in Flash that allows you to easily monitor memory usage and framerate. It’s simple, unobtrusive, and only adds 0.5kb to your SWF.
It’s only about 5 lines of code, but it’s handy to have kicking around your component panel for quick access.
Here’s a simple demo of it (it’s the little widget on the right). It just generates random ByteArray data to force the memory usage up and framerate down.
if (AC_FL_RunContent == 0) {
alert("This page requires AC_RunActiveContent.js.");
} else {
AC_FL_RunContent(
'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
'width', '550',
'height', '27',
'src', '/blog/assets/memoryGauge',
'quality', 'high',
'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
'align', 'middle',
'play', 'true',
'loop', 'true',
'scale', 'showall',
'wmode', 'window',
'devicefont', 'false',
'id', 'RndmTest',
'bgcolor', '#FFFFFF',
'name', 'memoryGauge',
'menu', 'true',
'allowFullScreen', 'false',
'allowScriptAccess','sameDomain',
'movie', '/blog/assets/memoryGauge',
'salign', ''
); //end AC code
}
You can download the FLA for the above demo, and a SWC file that you can drop into your components directory by clicking here.
Hi,
Nice work Grant.
I released a similar set for Flash Lite developers recently. Its avaiable with source code at http://wiki.forum.nokia.com/index.php?title=Oxygen_-_The_Flash_Lite_Developers_Kit
I have included a bar-graph to show percentage of the FPS and Memory. Maybe you’d also add graphs to this component 🙂
// chall3ng3r //
Useful! I’ve already inserted it into my project. I wish it updated the fps field a little less often though. It’s flickers around so much that I can’t really read it.
Thanks! Just yesterday I wasted a few minutes looking for that “fps bar widget” that nearly all papervision3d experiments have in the top left corner… couldn’t find it, yours will do just fine 🙂
Nice! Small and simple. I can really but this to good use. Thanks!
Is there a way to mmake it work in flex? I linked the swc but I can’t find the classes. Thanks
chall3ng3r, I considered adding some features like this, but I like the simplicity of it as is.
Eric, I might add a bit of dampening. For my purposes I preferred the immediate feedback, but I realize a lot of people will likely want it to be averaged over a few frames.
Simon, not at present, but I’ll try to whip up a Flex version later today or tomorrow.
Not to say one is better or worse, but i’ve found this tool invaluable.
Idea is the same, however it tells you the average and the current, and there’s a graph that lets you watch as your memory usage creates peaks and valleys.
Also it’s as simple as:
var activeGraph = new ActiveGraph();
addChild(activeGraph);
————-
the author doesn’t have a website, but you can get it from here.
http://www.kirupa.com/forum/showthread.php?t=262507
Stupid question. I am just developing flash project.
How can I use the provided .swc file in Flash IDE? or need to use the library symbol in the provided .fla files.
Thx,
“drop into your components directory”
sorry, just being stupid….
Excellent little component. Thanks.
for flashdevelop :
add the memorygauge.swc to the lib folder then right click on it “add to library”
and in your app write this code :
var memoryLevel:MemoryGauge = new MemoryGauge();
addChild(memoryLevel);
Do you know of any AS2 memory gauge/components? Need one for a project. Thanks!