New tutorial on SWF framerate optimization
| I just finished uploading a new tutorial that explains how you can optimize your Flash movie’s framerate so that it only uses the resources that it needs to. Most of the time you only need a fast framerate for animation and you can structure your movie so that the rate is high only during those times. The tutorial also shows how to put your movie into a different mode when the user leaves your movie. |
Lee



cool, we get hated on alot for using a lot of system resources, thanks for being part of the solution lee
This is awesome Lee! I’ve been looking for how to do this. I’ve had a lot of trouble with getting papervision3D CPU usage down.
Thanks,
Steve
Great tutorial!!
Now I’m testing it in my little portfolio website
Cool, but don’t you have any before and after stats concerning cpu usage? And also why didn’t you use a more complex example? As that would have bin more relevant.
Lee regarding the 1 fps issue
its because the flash player can only force updates such as video or updateAfterEvent() at 10x the current framerate – so 1 fps will result in a max of 10 fps in ur video – and 5 would give it a reach of 50 fps
you can read about in my lab where i discovered this “bug”
http://thonbo.com/updateAfterEvent/updateAfterEvent.html
try to put it to 3 fps then it would be just over the top for the video but at 2 you would see a lag as for 20 fps
if you watch the “timer” bar that is suppose to run 1 event pr millisecond actually drops to 10 if you lower the framerate down to 1 – this would in theory be the same for the video’s individual fps –
but we still see the mouse movement event is still firing at – in my case 800 ms (logitech gaming mouse) – this actually differs from browser to browser – i guess its some kind of sequrity issue -
Love the videos.
Is the 1 frame per second which causes video to stutter a “bug” that will be fixed in later verisions of Flash Player?
Is the video stutter the only side effect of setting your frame rate to 1? If you didn’t have video in the example would it have worked fine at 1 FPS?
Hi Lee,
Great to have ya back in the saddle, given us these wicked tutorials.
I have but one small question, towards the end of the lesson, you place code in the staticRate function that applies the rate of 5 to the theRate var. Would this not overwrite the point of have the theRate = stage.frameRate in the leavingMode function.
I do not wish to offend a flash veteran like yourself, im just learning this and it confused me.
Paul
Great tutorial, like always … but I think you could put more on actionscript optimizations, perhaps even about one of the most used 3D engines, like papervision. Thanks Lee
Good one Lee
And it really increases performance
And please Lee don’t leave us that long again we miss you man and we miss your wonderful tutorials
wonderful and great thanks
Can you save your example files in CS3 form so us CS3 users can open them? Thanks!
Great Tutorial!
Very nice topic.
maybe it could be interesting to do a tut on garbage collection?
You just solved a resources problem that has been driving me crazy for weeks.
You’re the man.
Thanks,
Brad
You are my Avangelist. Thanks Lee – Sei GRANDE
What a pity,
In Iran we dont have a fast connection to download that movie.
I have to read long tutorials.
I have a 26kb internet disconnection…oh…God
Great tutorial Lee, I recently had to deal with optimizing a large flash app, and think if you could touch on the finer points of garbage collection it would do the flash world a big favor. GS wrote a great article, but think a tutorial showing use of system.totalMemory() – system.gc() would be great. Thanks again!
[...] fash framrate optimization http://theflashblog.com/?p=1138 Tagged with: ColdFusion, Flex, Flex 4, pureMVC, railo, swiz leave a comment « [...]
I will try myself .. thanks for nice tips ..
hi! thanks once again for this great tutorials…
i tried it, but i found that if you go away from the movie and come back very quickly it blocks on 5 f/s…there is no way back to 30 f/s
ok bye!
Hi Lee.
Is there a better way than reducing frameRate when the mouse cursor leaves the stage? Surely in many applications, the user may move their cursor off the stage in order to not interfere with the content.
I guess this is just the most simple example.
Lee,
I implemented this script for a video player with external chapter buttons. This caused the audio on the video to skip. Any thoughts? I was throttling from 5fps to 30fps.
Hi Lee,
great tutorial as always – thanks! A few of the other comments ask these questions but here goes:
1) Is there a reason why you didn’t choose to use system.pause() and system.resume()?
2) Would you consider giving more optimization/garbage collection info? I feel this is a big area that a lot of us really want to improve on.
Thanks again!
[...] New tutorial on SWF framerate optimization by lee [...]
Really great tutorial, I am on the verge of migration from AS2 to AS3, your tuts are really helpfull, that I always look around for my projects.
Thanks man,,,,,
sharat
[...] That was then, this is now! In Lee’s latest video tutorial, he demonstrates how you can dynamically change your movie’s framerate to use only the resources it [...]
@jim – You could try adjusting this bit of code to see memory use, but this won’t tell you that much about the CPU:
function loop(e:Event):void
{
rate.text = “FPS = ” + stage.frameRate.toString() + ” | Memory = ” + System.totalMemory;
}
You could try using Monster Debugger to get more stats on what’s going on.
Matt
@Lee,
Oh yeah, once again, great tutorial!
Hi Lee,
Would it be possible to provide the fla and AS3 files to drive this video via documentClass? This is one tutorial that is missing- specifically controlling a FLV video via documentClass and AS3.
Thanks.
[...] That was then, this is now! In Lee’s latest video tutorial, he demonstrates how you can dynamically change your movie’s framerate to use only the resources it [...]
Thanks Lee. That’s a simple but very, very useful technique.