Loader.load()

Availability

Flash Player 6 (6.0.79.0).

Edition

Flash MX 2004.

Usage

loaderInstance.load([path])

Parameters

path An optional parameter that specifies the value for the contentPath property before the load begins. If a value is not specified, the current value of contentPath is used as is.

Returns

Nothing.

Description

Method; tells the loader to begin loading its content.

Example

The following example creates a Loader instance, my_ldr, and a Button instance and sets the loader autoload property to false so that loading does not begin until a call to the load() method is made. Next the example sets contentPath to the web location of an image and creates a listener for a click event on the button. When the user clicks the button, the event handler calls my_ldr.load() to load the image. The event handler also disables the button.

Drag a Loader component and a Button component from the Component panel to the Library, then add the following code to the first frame of the timeline.

/**
 Requires:
  - Loader component in Library.
  - Button component in Library.
*/

System.security.allowDomain("http://www.flash-mx.com");

//Create loader instance.
this.createClassObject(mx.controls.Loader, "my_ldr", 10);
this.createClassObject(mx.controls.Button, "load_button", 20, {label:"Load image"});

my_ldr.move(0, 30);

my_ldr.autoLoad = false;
my_ldr.contentPath = "http://www.flash-mx.com/images/image1.jpg";

var loadListener:Object = new Object();
loadListener.click = function (evt_obj:Object) {
 my_ldr.load();
 load_button.enabled = false;
}
load_button.addEventListener("click", loadListener);