Loading external images

In Flash Lite 2.0, as in Flash Lite 1.1, you can use the loadMovie() function (or, equivalently, the loadMovie() method of the MovieClip object) to load external SWF files into your application. Additionally, in Flash Lite 2.0, you can use the loadMovie() function to load any arbitrary image format that the device supports.

For example, assuming that the target device can decode PNG files, the following code loads and displays an external PNG file that resides on the web server:

loadMovie("http://www.adobe.com/image.png", "image_target");

To determine what image formats the target device supports, you can use the System.capabilities.imageMIMETypes property, which contains an array of supported image MIME types. The index of each element in the array is equal to each supported MIME type.

For example, the following ActionScript determines whether a device supports PNG images before the device attempts to load an external PNG file:

if (System.capabilities.imageMIMETypes["image/png"]) {
    loadMovie("images/image.png", "mc_myPngImage");
}

Flash Lite limits to five the number of loadMovie() operations that an application can perform in a given frame, and 10 total operations at any one time. For example, suppose your application contains code on frame 1 to load six external JPEG images, as shown below:

image1.loadMovie("image1.jpg");
image2.loadMovie("image2.jpg");
image3.loadMovie("image3.jpg");
image4.loadMovie("image4.jpg");
image5.loadMovie("image5.jpg");
image6.loadMovie("image6.jpg"); // Won't load

In this case, only the first five images (image1.jpg through image5.jpg) will load; the last image (image6.jpg) will not load because the five connection limit is reached. One solution is to split the loadMovie() calls over multiple frames so that each frame contains a maximum of five loadMovie() calls.


Flash CS3

Take a survey