When you load external assets into a movie, you're loading a media file (such as an MP3 file, a JPG graphic, a video, or even another SWF) into a Flash movie as it plays. In other words, you're adding assets to your movie. In fact, you can create a Flash movie that contains nothing but script set up to load text, animations, graphics, and sounds from external assets. Media that's loaded dynamically in this fashion can exist on a Web server or on a disk or CD if your project is distributed as a projector; therefore, a single project can load media from several sources simultaneously. All that's usually required is the directory path to the files. It's that simple! No special server technologies required. Sometimes, as is the case when loading media files from a disk or CD, not even a server is needed.
By loading external assets (rather than placing all of your project's media in a single SWF), your project benefits in a number of ways:
Your movie downloads faster over the Web. Imagine that you have a site containing four sectionsHome, Services, Products, and Contacteach of which has its own graphic and soundtrack. Together, the graphic and soundtrack add 100 KB to each sectiona total of 400 KB if you place everything in a single SWF. For users connecting via 56 Kbps modems, your site will take nearly two minutes to downloada sure way to turn viewers away. You're better off loading each section's graphic/soundtrack on an as-needed basis, or only when a user navigates to that sectionthe approach that most HTML-based sites take.
You can view multiple movies in the player window without navigating to different HTML pages. When using a browser to navigate Web sites, you don't need to close one window and then open another just to move from page to page. Instead, the browser remains open while the window's content changes as pages are loaded and unloaded. The same thing happens when external movies are loaded into Flash's player window: The player window simply acts as a container whose contents (a Flash movie) change without the user having to close the movie window or navigate to a different HTML page.
Your project becomes modularand thus easy to update and reuse. When you begin using assets loaded from external sources in your project, Flash movies become nothing more than interactive modules that you can load (plug into) your project at will. Any revisions to a particular module will appear automatically in any other project that contains it. Think again of a standard Web site: Even though each graphic (for example, a logo) usually resides in a single location on the server, multiple pages can contain that logo simply by referencing its directory path on the serverso you don't need to create a separate logo graphic for each page. You can reuse that graphic on any number of pages, and all of the pages on which it appears will reflect those changes anytime you update that graphic. The same holds true for externally loaded content in your Flash projectsa benefit that cannot be overemphasized because it's much easier to individually edit several smaller, externally loaded files than to open a complex project with numerous scenes, layers, tweens, movie clip instances, and scripting every time you need to make a change.
Your project becomes more dynamic, offering each user a unique experience. By loading external assets, you can provide the user with a much more dynamic experience, employing a wider range of content that loads based on time of day, month, user input, or even a randomly generated number.
Although it would be next to impossible to create a single SWF that could display appropriate content based on so many variables, using externally loaded assets makes this type of dynamic functionality a breeze.
You can load external assets by using loadMovie() or loadMovieNum() for external SWF or JPG files, or loadSound() for external MP3s. Video assets can be loaded using an instance of the netStream() class; however, the Media components provide a much easier interface for getting video (and MP3) content into your project, as we'll discuss later in this lesson.
In the following exercises, you'll learn how to load a variety of external file types, and how to control these assets using ActionScript.