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

Comments

  1. July 8th, 2009 | 6:04 pm

    cool, we get hated on alot for using a lot of system resources, thanks for being part of the solution lee

  2. July 8th, 2009 | 7:10 pm

    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

  3. July 8th, 2009 | 7:35 pm

    Great tutorial!!
    Now I’m testing it in my little portfolio website :)

  4. jim
    July 9th, 2009 | 1:28 am

    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.

  5. July 9th, 2009 | 3:21 am

    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

  6. July 9th, 2009 | 3:23 am

    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

  7. July 9th, 2009 | 3:28 am

    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 -

  8. Billy
    July 9th, 2009 | 5:03 am

    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?

  9. dabouncer
    July 9th, 2009 | 7:11 am

    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

  10. ricardo
    July 9th, 2009 | 7:28 am

    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 :)

  11. Nabeel
    July 9th, 2009 | 9:07 am

    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

  12. nacho
    July 9th, 2009 | 9:40 am

    wonderful and great thanks

  13. steve
    July 9th, 2009 | 9:56 am

    Can you save your example files in CS3 form so us CS3 users can open them? Thanks!

  14. Lou
    July 9th, 2009 | 4:00 pm

    Great Tutorial!

  15. July 9th, 2009 | 4:17 pm

    Very nice topic.

    maybe it could be interesting to do a tut on garbage collection?

  16. Brad Sedito
    July 10th, 2009 | 6:48 am

    You just solved a resources problem that has been driving me crazy for weeks.
    You’re the man.

    Thanks,
    Brad

  17. flashdev.it
    July 10th, 2009 | 7:58 am

    You are my Avangelist. Thanks Lee – Sei GRANDE :)

  18. July 10th, 2009 | 10:30 am

    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

  19. July 11th, 2009 | 11:43 am

    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!

  20. July 13th, 2009 | 3:32 am

    [...] fash framrate optimization http://theflashblog.com/?p=1138 Tagged with: ColdFusion, Flex, Flex 4, pureMVC, railo, swiz leave a comment « [...]

  21. July 13th, 2009 | 7:09 am

    I will try myself .. thanks for nice tips ..

  22. July 13th, 2009 | 11:42 pm

    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!

  23. July 14th, 2009 | 9:15 am

    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.

  24. July 14th, 2009 | 9:29 pm

    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.

  25. July 15th, 2009 | 2:41 am

    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!

  26. July 17th, 2009 | 6:22 am

    [...] New tutorial on SWF framerate optimization by lee [...]

  27. sharat achary
    July 18th, 2009 | 4:35 am

    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

  28. July 21st, 2009 | 6:00 am

    [...] 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 [...]

  29. July 21st, 2009 | 9:14 am

    @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 :)

  30. July 21st, 2009 | 9:15 am

    @Lee,

    Oh yeah, once again, great tutorial!

  31. Gary
    July 22nd, 2009 | 12:10 pm

    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.

  32. August 4th, 2009 | 10:41 pm

    [...] 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 [...]

  33. August 9th, 2009 | 10:40 am

    Thanks Lee. That’s a simple but very, very useful technique.

Leave a reply