views:

1023

answers:

5

I have a project with only a couple of graphics and lots of ActionScript 3. Anyone have any tips on reducing SWF file size?

A: 

Increase the compression of the graphics (such as lowering the jpg quality) and look for parts of your code that are not being used and see if you can trim or refactor.

Chris Ballance
+2  A: 

You can do couple of things..

  • save images as external links and load those dynamically(there is a trade off)

  • check SIZE REPORT , track down and trim down the large embedded files

Omnipotent
+1  A: 

Graphics should always be the first suspect in cases of file bloat. If you have images, reduce quality or size, or see if a different format yields smaller file sizes. Don't copy-paste vector drawings, put them in a movie clip or graphic and put that in other places. Also, if you have any sort of complicated vector art, smoothing can help reduce their complexity.

Action script can be reduced just as you would reduce any other code. Look for repetitions and other places that can be cut out. But honestly file size is not impacted much by code.

Somewhat related question: Why does my SWF file size not decrease when reducing content?

mgbennet
+3  A: 

First thing to do is turn on the size report (Don't have Flash handy, but should be in publish settings) and take a look at what is really taking up that space. From your description, it should mostly be in actionscript.

If you have any dynamic or text fields with embedded fonts, be careful you are embedding only the subset of characters you need, if you are using bitmaps, make sure you are using appropriate compression (lossless is actually better for 'computery' images, lots of solid colors or simple gradients).

As for reducing actionscript byte size... try the obvious things first: use publish or test instead of debug (Shift-F12 or Ctrl-Enter, not Ctrl-Shift-Enter) to compile release code, double-check that there are not flash built-in functions you can use instead of actionscript, use functions to share code, add local variables to reduce common sub-expressions.

You could try one of avoiding dynamic objects or using them more... each class has overhead for it's description, but I think they may have less overhead for member accesses. I have not tested this either way, though.

Either trim or copy out any methods you are using from other libraries. If you are using Flex... sorry, you are pretty boned :(. Watch out for class references that pull in a whole bunch of unused classes: making a trimmed private library copy is useful here as well.

If you are willing to sacrifice code quality: you could try using class members instead of parameters for deep call heirachies. Look out for inner functions - there are a few situations that can cause bloat. Since names are included (once), even using shorter package, class and member names (not parameter or locals), and literals instead of constants, so only the value has to be emitted, not the member name as well (I am not sure about private members, or in sealed classes).

Simon Buchan
+2  A: 

Runtime shared library

John Isaacks