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).
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.
You can force Flash to compact a FLA file in two ways:
This option forces Flash to remove unnecessary information during the save. Flash has to rewrite the entire file, so the operation may take longer, depending on the amount of content to save. You won't be able to reopen the file in previous versions of Flash, so be careful to retain backups of the legacy FLAs! It is a good idea to save a backup under another name in case the compact operation fails for some reason.
This option does the same thing as FileSave and Compact but it assumes you will rename the file. Using another name is a good idea in case the file save operation fails, but you can save it using the original filename by clicking Yes when warned that a file of that name already exists.
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:
Press Ctrl-S (or -S) to save the file every so often. This saves the file instantaneously so you can carry on without any pause.
Make a backup of your file periodically to avoid losing any work or allowing you to go back to a previous version if you need to for some reason.
Select FileSave As or FileSave and Compact on occasion (such as at the end of the day or before archiving files) to compact the file.
Before permanently archiving a FLA file, save a backup copy. Then delete unused assets from the Library (bearing in mind that assets used via ActionScript should not be deleted). Then save and compact the file using one of the preceding techniques in order to minimize the FLA for archival purposes.
Although 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.