Using the Loader component

You can use a loader whenever you need to grab content from a remote location and pull it into a Flash application. For example, you could use a loader to add a company logo (JPEG file) to a form. You could also use a loader to leverage Flash work that has already been completed. For example, if you had already built a Flash application and wanted to expand it, you could use the loader to pull the old application into a new application, perhaps as a section of a tab interface. In another example, you could use the loader component in an application that displays photos. Use Loader.load(), Loader.percentLoaded, and Loader.complete to control the timing of the image loads and display progress bars to the user during loading.

Loader component parameters

The following are authoring parameters that you can set for each Loader component instance in the Property inspector or in the Component Inspector panel:

autoload indicates whether the content should load automatically (true), or wait to load until the Loader.load() method is called (false). The default value is true.

content an absolute or relative URL indicating the file to load into the loader. A relative path must be relative to the SWF loading the content. The URL must be in the same subdomain as the URL where the Flash content currently resides. For use in the stand-alone Flash Player or for testing in test-movie mode, all SWF files must be stored in the same folder, and the filenames cannot include folder or disk drive specifications. The default value is undefined until the load had started.

scaleContent indicates whether the content scales to fit the Loader (true), or the Loader scales to fit the content (false). The default value is true.

You can write ActionScript to set additional options for Loader instances using its methods, properties, and events. For more information, see Loader class.

Creating an application with the Loader component

The following procedure explains how to add a Loader component to an application while authoring. In this example, the loader loads a logo JPEG from an imaginary URL.

To create an application with the Loader component, do the following:

  1. Drag a Loader component from the Components panel to the Stage.
  2. Select the loader on the Stage and use the Free Transform tool to size it to the dimensions of the corporate logo.
  3. In the Property inspector, enter the instance name logo.
  4. Select the loader on the Stage and in the Component Inspector panel do the following:
    • Enter http://corp.com/websites/logo/corplogo.jpg for the contentPath parameter.