DekGenius.com
[ Team LiB ] Previous Section Next Section

Introduction

Loading external .swf files into a Flash movie has long been a part of ActionScript. Beginning with Flash Player 6 it is also possible to load JPEG and MP3 files into a Flash movie at runtime. The implications of this are rather important. There are many good reasons for loading external content into your Flash movies at runtime, such as:

  • It is easier and more convenient to manage external assets than to have to open the Flash document, import new or modified assets, and re-export the .swf file each time you want to make a change.

  • In larger applications it makes sense to have different .swf files that are authored by different people or teams that can be assembled at runtime by a main, loading movie. This solves the bottleneck problems that can occur when trying to author a single .swf file (since only one person at a time can edit a Flash document).

  • By loading external assets, you can create applications in which users can load their own assets into the Flash movie (for an example, see the jukebox application in Chapter 26).

  • Loading external assets at runtime enables you to download assets to the client's computer as they are requested. This is important for large applications. For example, consider an application that allows a user to view photographs of a room in order to select a paint color. The application might allow a user to select from 90 colors, and each color selection might display a different version of the same photograph in which the walls have been painted that color. It is likely that most users will not view all 90 images, so it makes sense to avoid downloading all the images (which could create a significant increase in initial download time). Instead, the appropriate images can be downloaded as they are requested.

The preceding list includes just a few of the many benefits of loading external assets. Undoubtedly, you can discover more as you create your own application.

In the recipes throughout this chapter, you can find solutions to all kinds of problems related to loading external, binary assets at runtime. Binary assets include SWFs, JPEGs, and MP3s. For more information about loading textual data see the recipes dealing with the LoadVars and XML classes in Chapter 18 and Chapter 19.

    [ Team LiB ] Previous Section Next Section