Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reducing SWF File Size

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

like image 664
jspooner Avatar asked Feb 20 '09 06:02

jspooner


People also ask

How do I compress a SWF file?

Step 1Open your browser and search VEED.io on the search box. Then, click the Choose Video button, then the Upload a File button to upload your SWF file. Step 2And then, move the slider to the Smaller File option to reduce the size of your video. Step 3Click the Compress button to start compressing your video.

What is the file size of SWF?

File size is 76 bytes (4 bytes at offset 4, hex: 4C 00 00 00). Thus reading of all 76 consecutive bytes starting from the position of detected FWS header provide us with all SWF file data.

How do I reduce the size of a FLA file?

The way to reduce the fla file size is to delete assets inside your project you dont need. 2. Doing "saves as" will reduce file massively.

Which option is used to reduce the file size in flash?

Use the Optimize Curves dialog box (Modify > Shape > Optimize) to reduce the number of vectors in a drawing. Select the Use Multiple Passes option for more optimization. Optimizing a graphic reduces file size, but compressing it too much compromises its quality.


2 Answers

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).

like image 137
Simon Buchan Avatar answered Sep 22 '22 12:09

Simon Buchan


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?

like image 34
mgbennet Avatar answered Sep 21 '22 12:09

mgbennet