Skip to content
Dec 19 / Peter deHaan

Determining whether a UILoader component auto loads content in Flash using ActionScript 3.0

The following example shows how you can control whether content is auto-loaded in a Flash ActionScript 3.0 UILoader container by setting the Boolean autoLoad property. If the autoLoad property is set to true, the content is automatically loaded whenever the source property is set or the load() method is called. If the autoLoad property is false, the content will not be loaded until the load() method is explicitly called.

Full code after the jump.

// ActionScript 3.0
/* Requires
 * - UILoader control in Flash library
 * - Button control in Flash library
 */
import fl.containers.UILoader;
import fl.controls.Button;
 
var uiLoader:UILoader = new UILoader();
uiLoader.autoLoad = false;
uiLoader.source = "http://helpexamples.com/flash/images/image1.jpg";
uiLoader.move(10, 10);
addChild(uiLoader);
 
var button:Button = new Button();
button.label = "Load image";
button.addEventListener(MouseEvent.CLICK, button_click);
button.move(10, 120);
addChild(button);
 
function button_click(evt:MouseEvent):void {
    uiLoader.load();
}
Leave a Comment