Creating an application with the UILoader

The following procedure explains how to add a UILoader component to an application while authoring. In this example, the loader loads a GIF image of a logo.

To create an application with the UILoader component:

  1. Create a new Flash file (ActionScript 3.0) document.
  2. Drag a UILoader component from the Components panel to the Stage.
  3. In the Property inspector, enter the instance name aUI.
  4. Select the loader on the Stage and in the Component inspector, and enter http://www.helpexamples.com/images/logo.gif for the source parameter.

This example creates a UILoader component using ActionScript and loads a JPEG image of a flower. When the complete event occurs, it displays the number of bytes loaded in the Output panel.

To create a UILoader component instance using ActionScript:

  1. Create a new Flash file (ActionScript 3.0) document.
  2. Drag the UILoader component from the Components panel to the Library panel.
  3. Open the Actions panel, select Frame 1 in the main Timeline, and enter the following ActionScript code:
    import fl.containers.UILoader;
    
    var aLoader:UILoader = new UILoader();
    aLoader.source = "http://www.flash-mx.com/images/image1.jpg";
    aLoader.scaleContent = false;
    addChild(aLoader);
    
    aLoader.addEventListener(Event.COMPLETE, completeHandler);
    function completeHandler(event:Event) {
        trace("Number of bytes loaded: " + aLoader.bytesLoaded);
    }
    
  4. Select Control > Test Movie.