Extensive Optimization and File Size Tutorial
by jmtb02
After this tutorial, you should understand:
*Sound Compression
*Pre-flash Optimization of Audio
*Controlling Audio Compression within the Flash Environment
*Minimizing file size
*Vector vs. Bitmap
*What All Those Trace Bitmap Fields Actually Do
*Anti-Aliasing Text
*Symbol and Graphic Usage
*Other Tips
This is my first tutorial, so bear with it. Hopefully it will be appended to the very bottom of the AS:Main for future reference. There have been several threads floating through the forum concerning how to knock down file sizes for Newgrounds, getting the FLA file size down, etc. I thought it would be generally helpful to provide a help source for getting the file size down and to keep the flash environment streamlined.
Differing from T-H's Tutorial, I hope to provide a less script-based optimization method, which could be more useful towards animators and lesser programmers who, most likely, would not be using programming methods that are incredibly hard on the processing speed of flash.
Sound
Optimization of sound is one of the most important aspects of flash development. When music and sound files are imported into flash, they are going to play a huge role in the increase of .fla size, due to the library system flash incorporates. When sound files are imported into flash (via the File>Import>Import to Library/Import to Stage), they will be copied into the flash file, not linked externally. The means that the sound file will actually “live” inside the flash file, allowing the audio to travel with the .fla file if you were to move it to another computer.
However, the common misconception is that flash audio is copied file size for file size. This is not true, as the audio file expands massively when imported to Flash. Here is an example.
Hard Drive
Sound File: 4.6 MB/160 kbps
Flash
Same Sound File in Flash File: ~54.4 MB
As you can see, any sound file you add to flash is going to make your fla huge. Thus, it may be important to start optimizing in a secondary program, such as Audacity if you want to cut down the bloat. To do this, follow these steps:
1) Download Audacity and the LAME Encoder, and install the Audacity program. Drop the lame_enc.dll in the audacity directory.
2) Open the program, and hit File>Open. Find your mp3 file.
3) Hit File>Preferences, then hit the File Formats tab. In the box where it says “MP3 Export Setup”, hit find library. Select the lame_enc.dll that you stored in your program directory.
4) Drag the Bit Rate down to 64 (kbps). This will provide a good balance of bit rate and quality.
5) Close the Preferences panel. Click the Selection Tool, and select the audio you would like to have exported. Remember, the less audio you have, the smaller the file size will be. If you are just using 45 seconds of a song, there is no need to export the entire sound piece!
6) Hit File>Export Selection as Mp3. Now you should be able to export a nice, small file size. Import your sound file to Flash, and realize the size you have just fixed it at.
Hard Drive
Originally…
Sound File: 4.6 MB/160 kbps
Now…
Sound File: 1.7 MB/64 kbps
Flash
Originally…
Sound File: ~54.4 MB/160 kbps
Now…
Sound File: ~19.7 MB/64 kbps
Here are some more tips for keeping the flash file down…
*Sound loops can provide an infinite amount of music time for a much smaller file size. A 15 second loop will be much smaller, and it will be able to continually play over and over again as background music. This is very good for games that require a user to have the same music for a very long time.
*Setting the volume to zero within the “Edit Envelope” window will still export the sound. You may want to cut the sound clip down if you find yourself using a long sound file but turned most of the sound off.
*Switching from stereo to mono may also be helpful, as it can reduce the file size a lot. However, once again, you must strike a balance between file size vs. quality, so consider your options carefully.
SWF Size
Now that your FLA side is finished, now you can easily modify the swf side. If you did the optimization techniques from the previous section, you have much less work to do for the swf export.
In Flash, open up the File>Publish Settings window. Here you will find the options for how your flash will export. Click the “Flash” tab and look at the many options you have for flash; specifically, the bottom half of the window. You will find many options for sound publishing.
The first options are for the bit rate for the two different styles of sound in flash: Event and Streaming. Event sounds are sounds that will play independently of the timeline, while streaming sounds are sounds that will synchronize to the timeline, and flash will drop frames (if necessary) to keep up with the sync. You can probably guess when each will be more important.
However, back on topic, you will see the default set to 16 kbps. This means that for every second of flash, this will be the memory size of every second of music playback and storage (there are other factors, however, they will not be as important for flash). The default for flash is 16 kbps, which is pretty low quality when you compare it to an every day mp3 (128 kbps). However, you will notice when you export, that the file size is incredibly low. So what you need to do is strike a balance between quality and file size (say, 64 kbps, as we used earlier).
Please do not post... this is not the end of of the tutorial.... (1/4)
Hi there!
