2
votes

All,

I've been developing Flash applications for several years, and here's something I've always wondered about.

I try to be as careful as possible about minimizing the amount of "overhead" that my application uses. (By overhead, I generally mean RAM, cpu processing effort, downloaded data, etc.) My goal is to consume as little of the user's PC resources as possible.

So, I'm careful to:

  • include the fewest classes possible
  • minimize the scope of arrays, references, variables, etc
  • remove unnecessary clips, rather than hide them
  • minimize the number of fonts, and embed only the glyphs I actually need
  • carefully select graphics, and compress them as much as possible
  • etc.

(I know, I know... here's where all the anti-Flash folks chime in and say, "How 'bout not using Flash!")

Are there any rough guidelines about how much overhead various screen elements consume?

  • movie clips
  • static text
  • dynamic text
  • buttons
  • etc

For example... Let's say I have a screen element that might need to change based on the application's state. Is it less resource intensive to make it a dynamic text field than a movie clip?

Or, I'll often spend extra time creating complex screens with Actionscript rather than creating them in design-time in the IDE, because I naively believe that code is more compact/less overhead than elements pre-placed on the stage.

Or, for static elements, I typically use static text because I naively believe that it's less resource intensive than a dynamic text field. However, using a dynamic text field gives me extra flexibility than I might appreciate down the road in subsequent versions. Am I really saving anything here?

Or, what about buttons vs. movie clips? What about "device fonts" vs. "bitmap fonts" vs "anti-alias for animation" vs. "anti-alias for readability"?

I'll typically use the Task Manager's performance monitor, but it doesn't seem very sensitive to small changes, and it's hard to create controlled before/after comparisons.

Also important - I assume that a movieclip has more overhead than a static text field. However, is the difference at all worth worrying about? Am I wasting programming time trying to save a few bytes/CPU cycles that no one will ever notice?

A good analogy... I used to be incredibly careful about how I stored data. But now, storage is so cheap that it's not worth worrying about. It's far more important to focus on performance, maintainability, etc.

So - in Flash - is it worth spending hours trying to trim the number of clips from 500 to 400? Or, is the difference insignificant?

I appreciate that the circumstances matter - a few KB of "page weight" on Amazon.com or Twitter.com matter a lot more than on a site that gets a few hundred visitors a month. But in general, are there good tools to measure this type of thing? Good guidelines?

Many thanks in advance!

1
Add - Gradients, Sound, Video, Complex-Vectors to your list.madcolor
Madcolor - great points. That's exactly what I'm not sure about. Intuitively, I guess that a gradient is more "overhead" than a solid; alpha is more overhead than opaque, etc. But I don't know if I'm sweating irrelevant details here or not.mattstuehler
Add 'remove event listeners' to your first list. And unless you are writing a big app like an animation rich flash web site (like this aglassandahalffullproductions.com ) I don't think changing static text to dynamic or gradient to solid are gonna make a noticeable difference.Amarghosh

1 Answers

1
votes

Well, it depends how deep a class goes in terms of hierarchy i.e. DisplayObjectContainers are going to take more resources then DisplayObjects because former has more variables and functionalities than the later. So if you need to show some graphic, but don't want to change it during the course of swf then it is better to make it a Shape instead of MovieClip or Sprite. Buttons are obviously less costly then MovieClips and Sprites, and Sprites are less costly than MovieClips (as Sprites have only one frame). So it is good to be careful while choosing the appropriate class for your requirements. Events can have weak reference.