2

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.

Amarghosh
  • 58,710
  • 11
  • 92
  • 121
davr
  • 18,877
  • 17
  • 76
  • 99
  • Reduce the bit rate of any included sound files. Make them mono instead of stereo. Most of the time you won't notice the difference. Also, reduce the bit depth of included graphics. – BoltBait Oct 12 '09 at 22:59
  • You might already know this - the release build of a flex movie is only half the size of the normal debug version. – Amarghosh Oct 13 '09 at 04:48

5 Answers5

5

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
  • 1,575
  • 13
  • 23
  • 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 Oct 14 '09 at 20:15
1

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
  • 3,339
  • 2
  • 21
  • 24
1

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
  • 6,026
  • 4
  • 43
  • 51
  • 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 Oct 14 '09 at 19:31
1

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
  • 227
  • 4
  • 12
1

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

Community
  • 1
  • 1
enzuguri
  • 818
  • 5
  • 10