views:

797

answers:

7

Are there any tips / best practices / secrets for optimizing the size of AS3 SWF files? In particular, any way to get a breakdown of what is taking up space inside the SWF, like you used to be able to in the old Flash 7/8 days? I'm not using the Flash IDE any more, but now I'm using either Flex Builder or FlashDevelop, so it needs to be something that I can do without the Flash IDE.

+4  A: 

If you're interested what in the code is taking up space, you can get that information from the link report. It's not as detailed as what you can get out of the Flash IDE, but it shows the size of each class (uncompressed.)

To create a link report, use the -link-report <filename> flag on mxmlc. It creates an XML file with information about the classes linked into your SWF.

I used the .XSL file described in the link below to clean it up and make it more readable: http://blog.iconara.net/2007/02/25/visualizing-mxmlcs-link-report/

thehiatus
This is pretty cool...one wrinkle I found though. If you have multiple modules in your Flex project, it uses the same link-report.xml file for all of them, meaning it's only possible to see the report of the last compiled file
davr
+1  A: 

One tip would be to try Joa Ebert's "Reducer" tool which can greatly reduce the size of any PNG files in your SWF if you used the embed tag.

http://blog.joa-ebert.com/2009/08/08/reducer/

Allan
+1  A: 

Make sure, you use PNG-8 where it is possible and PNG-24 where you need alpha-channel. Use pngout tool to optimize them.
And there are some tools that can obfuscate and optimize SWF files.

Pavel Alexeev
Actually I learned you can have PNG-8 with an alpha channel, I'm using that in a couple places now. It's a bit tricky, since most of the major gfx tools don't support PNG8 with an alpha channel, only with a 1-bit transparency on/off mask. So you have to save a PNG24 file, then use a little converter to output PNG8 with alpha.
davr
A: 

I'm not sure what can be done with Flex Builder or FlashDevelop but what I always watch out for is font embedding. I take care to embed only the characters which will definately be used in the final swf.

Baldur
+1  A: 

Hi I previously posted this link in a related question about link report analysis (here), I've used this in the past and its quite a nice tool

LinkReportAIR

+1  A: 

check this link to optimize flex swf file size

http://askmeflash.com/article/9/optimize-flex-swf-filesize-performance-loading

Rex
A: 

To reduce swf file size for flash cs you can check out this link:

http://askmeflash.com/article/14/steps-to-optimise-swf-file-size-reduce-swf-size-how-to

Robert