Table of Contents |
Hack 65 Beat Flash File Bloat
You may find that your FLA gets bigger every time you save it, even if you delete unused assets such as bitmaps and sounds. Beat the bloat with this hack. When deploying Flash content online, filesize is the name of the game. The smaller the file you deploy, the faster it downloads. When compiling a FLA into a SWF, Flash omits unused assets in the Library [Hack #73] . However, the source FLA file contains not only unused Library assets, but even old assets that you have deleted from the Library! This is the cause of Flash FLA file bloat. It doesn't affect SWFs, but it is something to be aware of nonetheless. In versions of Flash prior to Flash MX 2004, you will find that your files get larger each time you save them using FileSave, even after you delete unused content from them. Although Flash MX 2004's FileSave and Compact option reduces the FLA file's size, this option isn't available in prior versions of Flash. Furthermore, saving the FLA in Flash MX 2004 format prevents you from reopening the file in previous versions (although Flash MX 2004 and Flash MX Professional 2004 share the same file format). Why the Big File?You may wonder what causes the file bloat in the first place. In all versions of Flash, saving a FLA using FileSave adds only incremental changes to the FLA (known as an incremental save or fast save). Flash doesn't optimize the saved file by removing things you've deleted. You can see this for yourself by creating a new Flash FLA file and importing a large media file (such as a bitmap or sound file). Then, save the file with FileSave or Ctrl-S (Windows) or -S (Mac) and note the file's size. Then delete the large media asset from both the Stage and the Library and resave the file with FileSave. You will see that the filesize remains constant even after deleting the large assets! This is the root of the bloat problem; as you make changes to a FLA file, the deletions are never removed from the saved file. This can also be problematic if you delete some embarrassing or proprietary content and then inadvertently pass it onto a client (granted, the client would need to decompile the FLA [Hack #98] to get at it, but it is always a good idea to cover your tracks). Although you ordinarily would publish only SWF files, you should compact FLA files when, say, posting them as examples on the Web or transmitting them to clients or other developers. The FixYou can force Flash to compact a FLA file in two ways:
So, why doesn't Macromedia change it so that the FileSave option performs a save and compact? Well, incremental saves can be considerably faster. Therefore, the optimal workflow is:
Final ThoughtsAlthough the bloat quirk is addressed in Flash MX 2004, you still need to know what's going on to manage it effectively within your workflow. Flash development often incorporates many design and asset changes, so files can get bloated very quickly. Minimizing the size of FLA files makes them load faster in the authoring tool and saves space when archiving or transmitting the FLA. Similar issues exist in many other commercial software products, including Macromedia Director and Microsoft Word. |
Table of Contents |