Packagecom.greensock.loading
Classpublic class XMLLoader
InheritanceXMLLoader Inheritance DataLoader Inheritance LoaderItem Inheritance LoaderCore Inheritance flash.events.EventDispatcher

Loads an XML file and automatically searches it for LoaderMax-related nodes like <LoaderMax>, <ImageLoader>, <SWFLoader>, <XMLLoader>, <DataLoader> <CSSLoader>, <MP3Loader>, etc.; if it finds any, it will create the necessary instances and begin loading them if they have a load="true" attribute. The XMLLoader's progress will automatically factor in the dynamically-created loaders that have the load="true" attribute and it won't dispatch its COMPLETE event until those loaders have completed as well (unless integrateProgress:false is passed to the constructor). For example, let's say the XML file contains the following XML: Example XML code:
<?xml version="1.0" encoding="iso-8859-1"?> 
<data>
         <widget name="myWidget1" id="10">
                <ImageLoader name="widget1" url="img/widget1.jpg" estimatedBytes="2000" />
        </widget>
         <widget name="myWidget2" id="23">
                <ImageLoader name="widget2" url="img/widget2.jpg" estimatedBytes="2800" load="true" />
        </widget>
         <LoaderMax name="dynamicLoaderMax" load="true" prependURLs="http://www.greensock.com/">
                 <ImageLoader name="photo1" url="img/photo1.jpg" />
                 <ImageLoader name="logo" url="img/corporate_logo.png" estimatedBytes="2500" />
                 <SWFLoader name="mainSWF" url="swf/main.swf" autoPlay="false" estimatedBytes="15000" />
                 <MP3Loader name="audio" url="mp3/intro.mp3" autoPlay="true" loops="100" />
         </LoaderMax>
</data>
 

Once the XML has been loaded and parsed, the XMLLoader will recognize the 7 LoaderMax-related nodes (assuming you activated the various types of loaders - see the activate() method for details) and it will create instances dynamically. Then it will start loading the ones that had a load="true" attribute which in this case means all but the first loader will be loaded in the order they were defined in the XML. Notice the loaders nested inside the <LoaderMax> don't have load="true" but they will be loaded anyway because their parent LoaderMax has the load="true" attribute. After the XMLLoader's INIT event is dispatched, you can get any loader by name or URL with the LoaderMax.getLoader() method and monitor its progress or control it as you please. And after the XMLLoader's COMPLETE event is dispatched, you can use LoaderMax.getContent() to get content based on the name or URL of any of the loaders that had load="true" defined in the XML. For example:

Example AS3 code:
var loader:XMLLoader = new XMLLoader("xml/doc.xml", {name:"xmlDoc", onComplete:completeHandler});
function completeHandler(event:LoaderEvent):void {
 
        //get the content from the "photo1" ImageLoader that was defined inside the XML
        var photo:ContentDisplay = LoaderMax.getContent("photo1");
        
        //add it to the display list 
        addChild(photo);
        
        //fade it in
        TweenLite.from(photo, 1, {alpha:0});
}

You do not need to put loader-related nodes in your XML files. It is a convenience that is completely optional. XMLLoader does a great job of loading plain XML data even without the fancy automatic parsing of loader data.

You may put extra data in the LoaderMax-related nodes that you'd like associated with that particular loader. XMLLoader will put all of the attributes from the XML node into the vars object of the resulting loader as well as an extra rawXML property which will contain the raw XML for that node. For example, if this node is in your XML document:

...
<VideoLoader url="video.flv" name="video1" description="Hidden dangers of steel wool" autoPlay="false">
    <links>
        <link url="http://www.greensock.com" title="GreenSock" />
        <link url="http://www.google.com" title="Google" />
    </links>
</VideoLoader>
...

Notice the "description" attribute which isn't a LoaderMax-specific property. XMLLoader will still put that value into the VideoLoader's vars property and create a rawXML property there that contains the whole XML node (including the children) so that you can easily get whatever data you need like this:

function completeHandler(event:LoaderEvent):void {
    var video:VideoLoader = LoaderMax.getLoader("video1");
    var description:String = video.vars.description;
    var xml:XML = video.vars.rawXML;
    trace("first link url: " + xml.links[0].link[0].@url); //traces "first link url: http://www.greensock.com"
}

Since XML is essentially text/string data, you cannot reference functions. Therefore it isn't possible to define onComplete, onInit, onError, etc. listeners inside XML. You can, however, add those via ActionScript once the XMLLoader has parsed the loaders. Simply use the standard addEventListener() method for that.

OPTIONAL VARS PROPERTIES

The following special properties can be passed into the XMLLoader constructor via its vars parameter which can be either a generic object or an XMLLoaderVars object:

Note: Using a XMLLoaderVars instance instead of a generic object to define your vars is a bit more verbose but provides code hinting and improved debugging because it enforces strict data typing. Use whichever one you prefer.

Note: If you don't want the fancy auto-parsing capabilities of XMLLoader, you can just use a DataLoader instead of XMLLoader. Then make the content into XML like: var xml:XML = new XML(myDataLoader.content);

XMLLoader recognizes a few additional attributes for dynamically-created loaders that are defined in the XML:

content data type: XML

Example AS3 code:
 import com.greensock.loading.*;
 import com.greensock.loading.display.*;
 import com.greensock.events.LoaderEvent;
 
 //we know the XML contains ImageLoader, SWFLoader, DataLoader, and MP3Loader data, so we need to activate those classes once in the swf so that the XMLLoader can recognize them.
 LoaderMax.activate([ImageLoader, SWFLoader, DataLoader, MP3Loader]);
 
 //create an XMLLoader
 var loader:XMLLoader = new XMLLoader("xml/doc.xml", {name:"xmlDoc", requireWithRoot:this.root, estimatedBytes:1400});
 
 //begin loading
 loader.load();
 
 //Or you could put the XMLLoader into a LoaderMax. Create one first...
 var queue:LoaderMax = new LoaderMax({name:"mainQueue", onProgress:progressHandler, onComplete:completeHandler, onError:errorHandler});
 
 //append the XMLLoader and several other loaders
 queue.append( loader );
 queue.append( new SWFLoader("swf/main.swf", {name:"mainSWF", estimatedBytes:4800}) );
 queue.append( new ImageLoader("img/photo1.jpg", {name:"photo1"}) );
 
 //begin loading queue
 queue.load();
 
 function progressHandler(event:LoaderEvent):void {
     trace("progress: " + event.target.progress);
 }
 
 function completeHandler(event:LoaderEvent):void {
     trace("load complete. XML content: " + LoaderMax.getContent("xmlDoc"));
    
    //Assuming there was an  node in the XML, get the associated image...
    var image:ContentDisplay = LoaderMax.getContent("image1");
    addChild(image);
 }
 
 function errorHandler(event:LoaderEvent):void {
     trace("error occured with " + event.target + ": " + event.text);
 }
 

Copyright 2010-2013, GreenSock. All rights reserved. This work is subject to the terms in http://www.greensock.com/terms_of_use.html or for Club GreenSock members, the software agreement that was issued with the membership.

See also

com.greensock.loading.data.XMLLoaderVars


Public Properties
 PropertyDefined By
 InheritedauditedSize : Boolean
[read-only] Indicates whether or not the loader's bytesTotal value has been set by any of the following: Defining an estimatedBytes in the vars object passed to the constructor Calling auditSize() and getting a response (an error is also considered a response) When a LoaderMax instance begins loading, it will automatically force a call to auditSize() for any of its children that don't have an estimatedBytes defined.
LoaderCore
 InheritedautoDispose : Boolean
When autoDispose is true, the loader will be disposed immediately after it completes (it calls the dispose() method internally after dispatching its COMPLETE event).
LoaderCore
 InheritedbytesLoaded : uint
[read-only] Bytes loaded
LoaderCore
 InheritedbytesTotal : uint
[read-only] Total bytes that are to be loaded by the loader.
LoaderCore
 Inheritedcontent : *
[read-only] The content that was loaded by the loader which varies by the type of loader: ImageLoader - A com.greensock.loading.display.ContentDisplay (a Sprite) which contains the ImageLoader's rawContent (a flash.display.Bitmap unless script access was denied in which case rawContent will be a flash.display.Loader to avoid security errors).
LoaderCore
 InheritedhttpStatus : int
[read-only] The httpStatus code of the loader.
LoaderItem
 InheritedloadTime : Number
[read-only] The number of seconds that elapsed between when the loader began and when it either completed, failed, or was canceled.
LoaderCore
 Inheritedname : String
A name that you use to identify the loader instance.
LoaderCore
 Inheritedpaused : Boolean
If a loader is paused, its progress will halt and any LoaderMax instances to which it belongs will either skip over it or stop when its position is reached in the queue (depending on whether or not the LoaderMax's skipPaused property is true).
LoaderCore
  progress : Number
[override] [read-only] A value between 0 and 1 indicating the overall progress of the loader.
XMLLoader
  RAW_LOAD : String = rawLoad
[static] Event type constant for when the XML has loaded but has not been parsed yet.
XMLLoader
 Inheritedrequest : URLRequest
[read-only] The URLRequest associated with the loader.
LoaderItem
 InheritedscriptAccessDenied : Boolean
[read-only] If the loaded content is denied script access (because of security sandbox restrictions, a missing crossdomain.xml file, etc.), scriptAccessDenied will be set to true.
LoaderItem
 Inheritedstatus : int
[read-only] Integer code indicating the loader's status; options are LoaderStatus.READY, LoaderStatus.LOADING, LoaderStatus.COMPLETED, LoaderStatus.PAUSED, and LoaderStatus.DISPOSED.
LoaderCore
 Inheritedurl : String
The url from which the loader should get its content.
LoaderItem
 Inheritedvars : Object
An object containing optional configuration details, typically passed through a constructor parameter.
LoaderCore
Public Methods
 MethodDefined By
  
XMLLoader(urlOrRequest:*, vars:Object = null)
Constructor
XMLLoader
 Inherited
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
[override]
LoaderCore
 Inherited
auditSize():void
[override] Attempts loading just enough of the content to accurately determine the bytesTotal in order to improve the accuracy of the progress property.
LoaderItem
 Inherited
cancel():void
If the loader is currently loading (status is LoaderStatus.LOADING), it will be canceled immediately and its status will change to LoaderStatus.READY.
LoaderCore
 Inherited
dispose(flushContent:Boolean = false):void
Disposes of the loader and releases it internally for garbage collection.
LoaderCore
  
getChildren(includeNested:Boolean = false, omitLoaderMaxes:Boolean = false):Array
Returns and array of all LoaderMax-related loaders (if any) that were found inside the XML.
XMLLoader
  
getContent(nameOrURL:String):*
Finds a particular loader's content from inside any loaders that were dynamically generated based on the xml data.
XMLLoader
  
getLoader(nameOrURL:String):*
Finds a particular loader inside any LoaderMax instances that were discovered in the xml content.
XMLLoader
 Inherited
load(flushContent:Boolean = false):void
Loads the loader's content, optionally flushing any previously loaded content first.
LoaderCore
  
parseLoaders(xml:XML, all:LoaderMax, toLoad:LoaderMax = null):void
[static] Parses an XML object and finds all activated loader types (like LoaderMax, ImageLoader, SWFLoader, DataLoader, CSSLoader, MP3Loader, etc.), creates the necessary instances, and appends them to the LoaderMax that is defined in the 2nd parameter.
XMLLoader
 Inherited
pause():void
Pauses the loader immediately.
LoaderCore
 Inherited
prioritize(loadNow:Boolean = true):void
Immediately prioritizes the loader inside any LoaderMax instances that contain it, forcing it to the top position in their queue and optionally calls load() immediately as well.
LoaderCore
 Inherited
resume():void
Unpauses the loader and resumes loading immediately.
LoaderCore
 Inherited
toString():String
[override] Returns information about the loader, like its type, its name, and its url (if it has one).
LoaderCore
 Inherited
unload():void
Removes any content that was loaded and sets bytesLoaded back to zero.
LoaderCore
Events
 Event Summary Defined By
 InheritedDispatched when the loader is canceled while loading which can occur either because of a failure or when a sibling loader is prioritized in a LoaderMax queue.LoaderCore
  Dispatched when any loader that the XMLLoader discovered in the XML dispatches a CANCEL event.XMLLoader
  Dispatched when any loader that the XMLLoader discovered in the XML dispatches a COMPLETE event.XMLLoader
  Dispatched when any loader that the XMLLoader discovered in the XML dispatches a FAIL event.XMLLoader
  Dispatched when any loader that the XMLLoader discovered in the XML dispatches an OPEN event.XMLLoader
  Dispatched when any loader that the XMLLoader discovered in the XML dispatches a PROGRESS event.XMLLoader
 InheritedDispatched when the loader completes.LoaderCore
 InheritedDispatched when the loader experiences some type of error, like a SECURITY_ERROR or IO_ERROR.LoaderCore
 InheritedDispatched when the loader fails.LoaderCore
  Dispatched when the loader's httpStatus value changes.XMLLoader
  Dispatched when the XML finishes loading and its contents are parsed (creating any dynamic XML-driven loader instances necessary).XMLLoader
 InheritedDispatched when the loader experiences an IO_ERROR while loading or auditing its size.LoaderItem
 InheritedDispatched when the loader starts loading.LoaderCore
 InheritedDispatched each time the bytesLoaded value changes while loading (indicating progress).LoaderCore
  Dispatched when any loader that the XMLLoader discovered in the XML dispatches a SCRIPT_ACCESS_DENIED event.XMLLoader
  Dispatched when the loader experiences a SECURITY_ERROR which can occur when the XML file is loaded from another domain and there is no crossdomain.xml file in place granting appropriate access.XMLLoader
 InheritedDispatched when the loader unloads (which happens when either unload() or dispose(true) is called or if a loader is canceled while in the process of loading).LoaderCore
Property Detail
progressproperty
progress:Number  [read-only] [override]

A value between 0 and 1 indicating the overall progress of the loader. When nothing has loaded, it will be 0; when it is halfway loaded, progress will be 0.5, and when it is fully loaded it will be 1.


Implementation
    public function get progress():Number
RAW_LOADproperty 
public static var RAW_LOAD:String = rawLoad

Event type constant for when the XML has loaded but has not been parsed yet. This can be useful in rare situations when you want to alter the XML before it is parsed by XMLLoader (for identifying LoaderMax-related nodes like <ImageLoader>, etc.)

Constructor Detail
XMLLoader()Constructor
public function XMLLoader(urlOrRequest:*, vars:Object = null)

Constructor

Parameters
urlOrRequest:* — The url (String) or URLRequest from which the loader should get its content.
 
vars:Object (default = null) — An object containing optional configuration details. For example: new XMLLoader("xml/data.xml", {name:"data", onComplete:completeHandler, onProgress:progressHandler}).

The following special properties can be passed into the constructor via the vars parameter which can be either a generic object or an XMLLoaderVars object:

  • name : String - A name that is used to identify the XMLLoader instance. This name can be fed to the LoaderMax.getLoader() or LoaderMax.getContent() methods or traced at any time. Each loader's name should be unique. If you don't define one, a unique name will be created automatically, like "loader21".
  • integrateProgress : Boolean - By default, the XMLLoader will automatically look for LoaderMax-related nodes like <LoaderMax>, <ImageLoader>, <SWFLoader>, <XMLLoader>, <MP3Loader>, <DataLoader>, and <CSSLoader> inside the XML when it inits. If it finds any that have a load="true" attribute, it will begin loading them and integrate their progress into the XMLLoader's overall progress. Its COMPLETE event won't fire until all of these loaders have completed as well. If you prefer NOT to integrate the dynamically-created loader instances into the XMLLoader's overall progress, set integrateProgress to false.
  • alternateURL : String - If you define an alternateURL, the loader will initially try to load from its original url and if it fails, it will automatically (and permanently) change the loader's url to the alternateURL and try again. Think of it as a fallback or backup url. It is perfectly acceptable to use the same alternateURL for multiple loaders (maybe a default image for various ImageLoaders for example).
  • noCache : Boolean - If noCache is true, a "gsCacheBusterID" parameter will be appended to the url with a random set of numbers to prevent caching (don't worry, this info is ignored when you getLoader() or getContent() by url and when you're running locally)
  • estimatedBytes : uint - Initially, the loader's bytesTotal is set to the estimatedBytes value (or LoaderMax.defaultEstimatedBytes if one isn't defined). Then, when the XML has been loaded and analyzed enough to determine the size of any dynamic loaders that were found in the XML data (like <ImageLoader> nodes, etc.), it will adjust the bytesTotal accordingly. Setting estimatedBytes is optional, but it provides a way to avoid situations where the progress and bytesTotal values jump around as XMLLoader recognizes nested loaders in the XML and audits their size. The estimatedBytes value should include all nested loaders as well, so if your XML file itself is 500 bytes and you have 3 <ImageLoader> tags with load="true" and each image is about 2000 bytes, your XMLLoader's estimatedBytes should be 6500. The more accurate the value, the more accurate the loaders' overall progress will be.
  • requireWithRoot : DisplayObject - LoaderMax supports subloading, where an object can be factored into a parent's loading progress. If you want LoaderMax to require this XMLLoader as part of its parent SWFLoader's progress, you must set the requireWithRoot property to your swf's root. For example, var loader:XMLLoader = new XMLLoader("data.xml", {name:"data", requireWithRoot:this.root});
  • autoDispose : Boolean - When autoDispose is true, the loader (and its children) will be disposed immediately after it completes (it calls the dispose() method internally after dispatching its COMPLETE event). This will remove any listeners that were defined in the vars object (like onComplete, onProgress, onError, onInit). Once a loader is disposed, it can no longer be found with LoaderMax.getLoader() or LoaderMax.getContent() - it is essentially destroyed but its content is not unloaded (you must call unload() or dispose(true) to unload its content). The default autoDispose value is false.
  • prependURLs : String - A String that should be prepended to all parsed LoaderMax-related loader URLs (from nodes like <ImageLoader>, <XMLLoader>, etc.) as soon as the XML has been parsed. For example, if your XML has the following node: <ImageLoader url="1.jpg" /> and prependURLs is set to "../images/", then the ImageLoader's url will end up being "../images/1.jpg". prependURLs affects ALL parsed loaders in the XML. However, if you have an <XMLLoader> node inside your XML that also loads another XML doc and you'd like to recursively prepend all of the URLs in this loader's XML as well as the subloading one and all of its children, use recursivePrependURLs instead of prependURLs.
  • maxConnections : uint - Maximum number of simultaneous connections that should be used while loading child loaders that were parsed from the XML and had their "load" attribute set to "true" (like <ImageLoader url="1.jpg" load="true" />). A higher number will generally result in faster overall load times for the group. The default is 2. Sometimes there are limits imposed by the Flash Player itself or the browser or the user's system, but LoaderMax will do its best to honor the maxConnections you define.
  • allowMalformedURL : Boolean - Normally, the URL will be parsed and any variables in the query string (like "?name=test&state=il&gender=m") will be placed into a URLVariables object which is added to the URLRequest. This avoids a few bugs in Flash, but if you need to keep the entire URL intact (no parsing into URLVariables), set allowMalformedURL:true. For example, if your URL has duplicate variables in the query string like http://www.greensock.com/?c=S&c=SE&c=SW, it is technically considered a malformed URL and a URLVariables object can't properly contain all the duplicates, so in this case you'd want to set allowMalformedURL to true.
  • skipFailed : Boolean - By default, XMLLoader will parse any LoaderMax-related loaders in the XML and load any that have their "load" attribute set to "true" and then if any fail to load, they will simply be skipped. But if you prefer to have the XMLLoader fail immediately if one of the parsed loaders fails to load, set skipFailed to false (it is true by default).
  • recursivePrependURLs : String - A String that should be recursively prepended to all parsed LoaderMax-related loader URLs (from nodes like <ImageLoader>, <XMLLoader>, etc.). The functionality is identical to prependURLs except that it is recursive, affecting all parsed loaders in subloaded XMLLoaders (other XML files that this one loads too). For example, if your XML has the following node: <XMLLoader url="doc2.xml" /> and recursivePrependURLs is set to "../xml/", then the nested XMLLoader's URL will end up being "../xml/doc2.xml". Since it is recursive, parsed loaders inside doc2.xml and any other XML files that it loads will all have their URLs prepended. So if you load doc1.xml which loads doc2.xml which loads doc3.xml (due to <XMLLoader> nodes discovered in each XML file), recursivePrependURLs will affect all of the parsed LoaderMax-related URLs in all 3 documents. If you'd prefer to only have the URLs affected that are in the XML file that this XMLLoader is loading, use prependURLs instead of recursivePrependURLs.

    ----EVENT HANDLER SHORTCUTS----

  • onOpen : Function - A handler function for LoaderEvent.OPEN events which are dispatched when the loader begins loading. Make sure your onOpen function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).
  • onRawLoad : Function - A handler function for XMLLoader.RAW_LOAD events which are dispatched when the loader finishes loading the XML but has NOT parsed the XML yet. This can be useful in rare situations when you want to alter the XML before it is parsed by XMLLoader (for identifying LoaderMax-related nodes like <ImageLoader>, etc.). Make sure your onRawLoad function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).
  • onInit : Function - A handler function for LoaderEvent.INIT events which are dispatched when the loader finishes loading the XML file, parses its contents, and creates any dynamic XML-driven loaders. If any dynamic loaders are created and have a load="true" attribute, they will begin loading at this point and the XMLLoader's COMPLETE will not be dispatched until the loaders have completed as well. Make sure your onInit function accepts a single parameter of type Event (flash.events.Event).
  • onProgress : Function - A handler function for LoaderEvent.PROGRESS events which are dispatched whenever the bytesLoaded changes. Make sure your onProgress function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent). You can use the LoaderEvent's target.progress to get the loader's progress value or use its target.bytesLoaded and target.bytesTotal.
  • onComplete : Function - A handler function for LoaderEvent.COMPLETE events which are dispatched when the loader has finished loading successfully. Make sure your onComplete function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).
  • onCancel : Function - A handler function for LoaderEvent.CANCEL events which are dispatched when loading is aborted due to either a failure or because another loader was prioritized or cancel() was manually called. Make sure your onCancel function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).
  • onError : Function - A handler function for LoaderEvent.ERROR events which are dispatched whenever the loader experiences an error (typically an IO_ERROR or SECURITY_ERROR). An error doesn't necessarily mean the loader failed, however - to listen for when a loader fails, use the onFail special property. Make sure your onError function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).
  • onFail : Function - A handler function for LoaderEvent.FAIL events which are dispatched whenever the loader fails and its status changes to LoaderStatus.FAILED. Make sure your onFail function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).
  • onIOError : Function - A handler function for LoaderEvent.IO_ERROR events which will also call the onError handler, so you can use that as more of a catch-all whereas onIOError is specifically for LoaderEvent.IO_ERROR events. Make sure your onIOError function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).
  • onHTTPStatus : Function - A handler function for LoaderEvent.HTTP_STATUS events. Make sure your onHTTPStatus function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent). You can determine the httpStatus code using the LoaderEvent's target.httpStatus (LoaderItems keep track of their httpStatus when possible, although certain environments prevent Flash from getting httpStatus information).
  • onSecurityError : Function - A handler function for LoaderEvent.SECURITY_ERROR events which onError handles as well, so you can use that as more of a catch-all whereas onSecurityError is specifically for SECURITY_ERROR events. Make sure your onSecurityError function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).
  • onChildOpen : Function - A handler function for LoaderEvent.CHILD_OPEN events which are dispatched each time any nested LoaderMax-related loaders that were defined in the XML begins loading. Make sure your onChildOpen function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).
  • onChildProgress : Function - A handler function for LoaderEvent.CHILD_PROGRESS events which are dispatched each time any nested LoaderMax-related loaders that were defined in the XML dispatches a PROGRESS event. To listen for changes in the XMLLoader's overall progress, use the onProgress special property instead. You can use the LoaderEvent's target.progress to get the child loader's progress value or use its target.bytesLoaded and target.bytesTotal. The LoaderEvent's currentTarget refers to the XMLLoader, so you can check its overall progress with the LoaderEvent's currentTarget.progress. Make sure your onChildProgress function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).
  • onChildComplete : Function - A handler function for LoaderEvent.CHILD_COMPLETE events which are dispatched each time any nested LoaderMax-related loaders that were defined in the XML finishes loading successfully. Make sure your onChildComplete function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).
  • onChildCancel : Function - A handler function for LoaderEvent.CHILD_CANCEL events which are dispatched each time loading is aborted on any nested LoaderMax-related loaders that were defined in the XML due to either an error or because another loader was prioritized in the queue or because cancel() was manually called on the child loader. Make sure your onChildCancel function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).
  • onChildFail : Function - A handler function for LoaderEvent.CHILD_FAIL events which are dispatched each time any nested LoaderMax-related loaders that were defined in the XML fails (and its status chances to LoaderStatus.FAILED). Make sure your onChildFail function accepts a single parameter of type LoaderEvent (com.greensock.events.LoaderEvent).

See also

Method Detail
getChildren()method
public function getChildren(includeNested:Boolean = false, omitLoaderMaxes:Boolean = false):Array

Returns and array of all LoaderMax-related loaders (if any) that were found inside the XML. For example, if the following XML was in the document, a child loader would be created for it immediately before the INIT event is dispatched:

<ImageLoader url="1.jpg" name="image1" />

Don't forget to use LoaderMax.activate() to activate the types of loaders that you want XMLLoader to recognize (you only need to activate() them once in your swf). Like LoaderMax.activate([ImageLoader, SWFLoader]); to ensure that XMLLoader recognizes <ImageLoader> and <SWFLoader> nodes.

No child loader can be found until the XMLLoader's INIT event is dispatched, meaning the XML has been loaded and parsed.

Parameters

includeNested:Boolean (default = false) — If true, loaders that are nested inside child LoaderMax, XMLLoader, or SWFLoader instances will be included in the returned array as well. The default is false.
 
omitLoaderMaxes:Boolean (default = false) — If true, no LoaderMax instances will be returned in the array; only LoaderItems like ImageLoaders, XMLLoaders, SWFLoaders, MP3Loaders, etc. The default is false.

Returns
Array — An array of loaders.
getContent()method 
public function getContent(nameOrURL:String):*

Finds a particular loader's content from inside any loaders that were dynamically generated based on the xml data. For example:

var loader:XMLLoader = new XMLLoader("xml/doc.xml", {name:"xmlDoc", onComplete:completeHandler});
function completeHandler(event:Event):void {
    var subloadedImage:Bitmap = loader.getContent("imageInXML");
    addChild(subloadedImage);
}

The static LoaderMax.getContent() method can be used instead which searches all loaders.

Parameters

nameOrURL:String — The name or url associated with the loader whose content should be found.

Returns
* — The content associated with the loader's name or url. Returns null if none were found.

See also

getLoader()method 
public function getLoader(nameOrURL:String):*

Finds a particular loader inside any LoaderMax instances that were discovered in the xml content. For example:

var xmlLoader:XMLLoader = new XMLLoader("xml/doc.xml", {name:"xmlDoc", onComplete:completeHandler});
function completeHandler(event:Event):void {
    var imgLoader:ImageLoader = xmlLoader.getLoader("imageInXML") as ImageLoader;
    addChild(imgLoader.content);
}

The static LoaderMax.getLoader() method can be used instead which searches all loaders.

Parameters

nameOrURL:String — The name or url associated with the loader that should be found.

Returns
* — The loader associated with the name or url. Returns null if none were found.
parseLoaders()method 
public static function parseLoaders(xml:XML, all:LoaderMax, toLoad:LoaderMax = null):void

Parses an XML object and finds all activated loader types (like LoaderMax, ImageLoader, SWFLoader, DataLoader, CSSLoader, MP3Loader, etc.), creates the necessary instances, and appends them to the LoaderMax that is defined in the 2nd parameter. Don't forget to make sure you activate() the necessary loader types that you want XMLLoader to recognize in the XML, like:

LoaderMax.activate([ImageLoader, SWFLoader]); //or whatever types you're using.

Parameters

xml:XML — The XML to parse
 
all:LoaderMax — The LoaderMax instance to which all parsed loaders should be appended
 
toLoad:LoaderMax (default = null) — The LoaderMax instance to which ONLY parsed loaders that have a load="true" attribute defined in the XML should be appended. These loaders will also be appended to the LoaderMax defined in the all parameter.

Event Detail
childCancel Event
Event Object Type: com.greensock.events.LoaderEvent

Dispatched when any loader that the XMLLoader discovered in the XML dispatches a CANCEL event.

childComplete Event  
Event Object Type: com.greensock.events.LoaderEvent

Dispatched when any loader that the XMLLoader discovered in the XML dispatches a COMPLETE event.

childFail Event  
Event Object Type: com.greensock.events.LoaderEvent

Dispatched when any loader that the XMLLoader discovered in the XML dispatches a FAIL event.

childOpen Event  
Event Object Type: com.greensock.events.LoaderEvent

Dispatched when any loader that the XMLLoader discovered in the XML dispatches an OPEN event.

childProgress Event  
Event Object Type: com.greensock.events.LoaderEvent

Dispatched when any loader that the XMLLoader discovered in the XML dispatches a PROGRESS event.

httpStatus Event  
Event Object Type: com.greensock.events.LoaderEvent

Dispatched when the loader's httpStatus value changes.

init Event  
Event Object Type: com.greensock.events.LoaderEvent

Dispatched when the XML finishes loading and its contents are parsed (creating any dynamic XML-driven loader instances necessary). If any dynamic loaders are created and have a load="true" attribute, they will begin loading at this point and the XMLLoader's COMPLETE will not be dispatched until the loaders have completed as well.

scriptAccessDenied Event  
Event Object Type: com.greensock.events.LoaderEvent

Dispatched when any loader that the XMLLoader discovered in the XML dispatches a SCRIPT_ACCESS_DENIED event.

securityError Event  
Event Object Type: com.greensock.events.LoaderEvent

Dispatched when the loader experiences a SECURITY_ERROR which can occur when the XML file is loaded from another domain and there is no crossdomain.xml file in place granting appropriate access.