Optimization in Flash MX

I thought I’d write a quick tutorial before I go out with my new lady friend tonight… I hope you guys like this… This gives you information about how to optimize your code or your movies in Flash…

Great for those of you who want to know information about what certain shapes do and how many of them your computer can most likely handle…

Optimization in Flash MX

Curves
The number one killer for most flash movies would have to be the “curves” and everything dealing with them. When you have an object that has 100+ curves in them and you try to move a couple of these things around at the same time… Things start to slow down in Flash.

Well Flash’s easiest Optimization tool is included with it… Modify - Optimization. While barely taking out any visual accuities of looking at that curve… It can make a 100+ curved object to about 70 without losing it’s original touch… And that is a big difference when you have a dozen of these fthings flying around.

Alpha
The story is… Alpha is slow… Many of you might think it’s a great effect but when your movieclip has an alpha less than 100… it starts to eat up time and memory… But why you are wondering…

Well… When a graphic has an alpha on it of say 75%… If that color is green and you run over another object that’s blue… Isn’t the area that those 2 objects intersect at a different color now?

See how they intersect and make new colors? That takes alot of extra calculations to make those new colors show themselves… Not too grand now is it? hehe…

Text
The truth is… text is slow… Especcially when you do alot of things with text… It is incredibly slow. The amount of curves in a single letter… And then having them in words… or even sentences can really rack up… And that isn’t good.

You don’t have to stay away from fonts or text… But try and minimize the number of changes you do to them dynamically… I’ll guarantee it’ll speed things up :slight_smile:

Gradients
Gradients are beautiful… Aren’t they? It seems like everything that’s beautiful is bad… lmao… But it’s true… Everything that is beautiful can be pretty much bad for optimization… it doesn’t matter which fill style you use with gradient… There are alot of colors in it and this makes it bad.

Try to not use gradients whenever you can and just substitue it with some extra lines in the curve and extra filling… You’re movie speed will thank you alot :wink:

Math Calculations
Another truth with Flash is… it’s not a Math Program… Of course it gives you all those lovely features for you to play with like sine and cosine and tangent and OoOoo… Goodies huh? Don’t use them…

Memory is alot faster than your computers calculations especcially in Flash… Use a look-up table to store all your cosine and sine datas… And then just multiply it out like that… Look up tables can be created easily and can be doen as soon as the movie loads up. That way it’s not performing caluclations while your movie is playing and it won’t put any additional sizes onto your movie either.


for(i=0; i<360; i++)
{
   mycos* = Math.cos(i * (Math.PI / 180));
   mysin* = Math.sin(i * (Math.PI / 180));
}

Now you can just call the mycos and mysin lookup tables and multply it that way… Makes your movie ALOT faster when you use look up tables instead of performing calculations outright during movie time. So always remember… Having 100+ variables is better than calculating things 100 times.

Since memory sdtandards are pretty much set at 64 megs and above… 100+ variables is nothing to that… hehe…

PC vs Mac’s FPS
This is a chart that I found… From Friends of Ed actually… That displays the differences in framerates between a PC and a MAC… Now these are avrages and different framerates are expecting for different comps… But kepe in mind… Make the Mac Speed high… The pc speed goes up to… Gotta keep it fair…

PC - MAC
1 - 1
2 - 2
3 - 3
4 - 4
5 - 5
6 - 6
7 - 7
8 - 8
9 - 9
10 - 9
11 - 10
12 - 10
13 - 12
14 - 12
15 - 12
16:20 - 15
21:30 - 19
31:58 - 29
59:120 - 57

That concludes my first section on Optimization… when I gte back form my date tonight… I’ll finish this off with actual MovieClips and their framerates when used in numbers. Helps out I swear.

This is some great stuff. Thanks very much for all the hints. It’s a great read when you are starting a new animation, lot’s of things to look out for

Hey playa!
That is a really nice tutorial. Would you be interested in having it up on the site - I’ll add it up if you want me to :slight_smile:

Cheers!
Kirupa :block:

Aww… thanks guys…

I’ll say this once… When I post tutorials on here they are “kirupa-exclusive” tutorials so feel free to psot any tutorial I write on here… I’ll be writing alot more as I find it enjoyable to :slight_smile: I’ll finish off this one tonight then… I was a little… Errm… Buys? so to speak last night :wink:

some great tips there playa - keep em commin’

:m: