User Guide
180 Display Programming
The LoaderInfo class
Once the file has loaded, a LoaderInfo object is created. This object is a property of both the
Loader object and the loaded display object. The LoaderInfo object is a property of the
Loader object through the
contentLoaderInfo property of the Loader object. It is a property
of the loaded display object through the display object’s
loaderInfo property. The
loaderInfo property of the loaded display object refers to the same LoaderInfo object as the
contentLoaderInfo property of the Loader object. In other words, a LoaderInfo object is
shared between a loaded object and the Loader object that loaded it (between loader and
loadee).
The LoaderInfo class provides information such as load progress, the URLs of the loader and
loadee, the number of bytes total for the media, and the nominal height and width of the
media. A LoaderInfo object also dispatches events for monitoring the progress of the load.
In order to access properties of loaded content, you will want to add an event listener to the
LoaderInfo object, as in the following code:
import flash.display.Loader;
import flash.display.Sprite;
import flash.events.Event;
var ldr:Loader = new Loader();
var urlReq:URLRequest = new URLRequest("Circle.swf");
ldr.load(urlReq);
ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, loaded);
addChild(ldr);
function loaded(event:Event):void
{
var content:Sprite = event.target.content;
content.scaleX = 2;
}
For more information, see Chapter 13, “Handling Events,” on page 345.