In Flash 8, you can load PNGs, GIFs, JPEGs and SWFs, but in the 6 and 7 player, you can only load JPEGs and SWFs. You can also load in .flv (Flash Video) files and MP3s, but that is beyond the scope of this chapter. (More on .flv and MP3 loading in Chapter 26, "Streaming Media.")
In earlier versions of the Flash player, you could only load nonprogressive JPEG files, but not in the 8 player, they can be progressive download and still work. Just keep this in mind when working on projects with earlier player versions.
You can load .swf files and the three image files into three places:
We will go over each method of loading in external files, but first, let's look at the difference in file size whether we load a file externally or we have it on the stage all the time.
Look at Figures 19.1 and 19.2. There is no difference in image quality, but notice the file size difference. Figure 19.1 was brought into Flash manually, and then the Flash file was compiled at a file size of 165 kilobytes. Now look at Figure 19.2, which shows exactly the same image, but it is being loaded in from an external source. The file size there is 82 bytes, not even one kilobyte in file size.
Figure 19.1. The image is within the Flash document.
Figure 19.2. The image has been loaded in dynamically.
Now, these figures have to be taken with a grain of salt. It is true that the file size of the Flash movie is decreased, but that does not mean that the image is smaller. In fact, the image size may be greater with an external file because Flash can compress JPEGs further.
So what does this mean if the file could have actually been smaller inside the Flash file rather than keeping it on the outside? Simplethe Flash file loaded the image when I told it to, and not before: content-on-demand.
And as far as large files from external sources taking a while to load, later in this chapter we cover preloaders for such an event.
Now you have seen it, but how do you do it?
For all examples, you can use your own external files, but for everything to be exactly as it is in the book, you should download the files for this chapter from the website.