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


Commentary

  1. leef says:

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

  2. Flash Framer says:

    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. vamapaull says:

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

  4. jim says:

    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. Thonbo says:

    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. Thonbo says:

    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. Thonbo says:

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

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

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

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

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

    wonderful and great thanks

  13. steve says:

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

  14. Lou says:

    Great Tutorial!

  15. vi54 says:

    Very nice topic.

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

  16. Brad Sedito says:

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

    Thanks,
    Brad

  17. flashdev.it says:

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

  18. 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. Erik Ketcham says:

    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. Vijay says:

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

  21. birdaleja says:

    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!

  22. paul says:

    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.

  23. Eddie says:

    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.

  24. gordee says:

    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!

  25. sharat achary says:

    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

  26. matbury says:

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

  27. matbury says:

    @Lee,

    Oh yeah, once again, great tutorial!

  28. Gary says:

    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.

  29. Allen Chou says:

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

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

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

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

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

Leave a Comment