loadMovie (MovieClip.loadMovie method)

public loadMovie(url:String, [method:String]) : Void

Loads SWF or JPEG files into a movie clip in a SWF file playing in Flash Lite.

Tip: To monitor the progress of the download, use the MovieClipLoader.loadClip() method instead of the loadMovie() method.

The loadMovie() method lets you display several SWF files at once and switch between SWF files without loading another HTML document.

A SWF file or image loaded into a movie clip inherits the position, rotation, and scale properties of the movie clip. You can use the target path of the movie clip to target the loaded SWF file.

Call loadMovie() to load any image format that the device supports. For example, if the target device supports PNG files, the following code loads and displays a PNG file that resides on a web server:
loadMovie("http://www.adobe.com/image.png", "image_target");
To determine what image formats the target device supports, 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 code 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. Flash Lite limits to ten the total loadMovie() operations at any one time. For example, suppose your application contains code on Frame 1 that loads six external JPEG images:
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) load. The last image (image6.jpg) does 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.

When you call the loadMovie() method, set the MovieClip._lockroot property to true in the loader movie, as shown in the following code example. If you don't set _lockroot to true in the loader movie, any references to _root in the loaded movie point to the _root of the loader instead of the _root of the loaded movie.

myMovieClip._lockroot = true;

Use the MovieClip.unloadMovie() method to remove SWF files or images loaded with the loadMovie() method.

Use the MovieClip.loadVariables() method, the XML object, Flash Remoting, or shared object to keep the active SWF file and load new data into it.

Using event handlers with MovieClip.loadMovie() can be unpredictable. If you attach an event handler to a button by using on(), or if you create a dynamic handler by using an event handler method such as MovieClip.onPress, and then you call loadMovie(), the event handler does not remain after the new content is loaded. However, if you attach an event handler to a movie clip by using onClipEvent() or on(), and then call loadMovie() on that movie clip, the event handler remains after the new content is loaded.

Availability

Flash Lite 2.0

Parameters

url:String - The absolute or relative URL of the SWF or JPEG file to be loaded. A relative path must be relative to the SWF file at level 0. Absolute URLs must include the protocol reference, such as http:// or file:///.

method:String [optional] - Specifies an HTTP method for sending or loading variables. The parameter must be the string GET or POST. If no variables are to be sent, omit this parameter. The GET method appends the variables to the end of the URL and is used for small numbers of variables. The POST method sends the variables in a separate HTTP header and is used for long strings of variables.

Example

The following example creates a new movie clip, then creates child inside of it and loads a PNG image into the child. This allows the parent to retain any instance values that were assigned prior to the call to loadMovie.

var mc:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth()); 
mc.onRelease = function():Void { 
    trace(this.image._url); // http://www.w3.org/Icons/w3c_main.png 
} 
var image:MovieClip = mc.createEmptyMovieClip("image", mc.getNextHighestDepth()); 
image.loadMovie("http://www.w3.org/Icons/w3c_main.png");