O'Reilly logo

Flash 8 Cookbook by Joey Lott

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

16.6. Optimizing Download Time by Sharing Content Among Movies

Problem

You are loading multiple .swf files into a single application using one of the techniques discussed in this chapter, and two or more of the .swf files happen to share one or more common elements, such as a movie clip, a sound, a bitmap, or a font. Rather than loading the same element multiple times, you want to load the element once and share it amongst the multiple .swf files.

Solution

Use a shared library.

Discussion

Shared libraries are a good way to reduce overall download size when the same element or elements are used across multiple .swf files in a single project. For example, if you have several .swf files that use the same embedded font, and if you embed the font in each of those files, you could be adding 10, 15, or even 20KB to the file size of each. Obviously that is not the greatest solution, because if you use that font in five .swf files in the same project, you could be adding 40 to 80KB to what the user has to download unnecessarily. Instead, what you can do is place the font in a shared library, link each of the .swf files to the shared library, and then require that the user only download the font once. The same idea applies not only to fonts, but to other types of elements including movie clips, buttons, graphics, bitmaps, and sounds.

There are essentially two steps when working with a shared library: creating the shared library and linking the .swf files to the shared library. Each of these steps ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required