ActionScript® 3.0 Reference for the Adobe® Flash® Platform
Home  |  Show Packages and Classes List |  Packages  |  Classes  |  What's New  |  Index  |  Appendixes
com.adobe.icomm.assetplacement.controller 

XMLDataLoader  - AS3 Asset Placement

Packagecom.adobe.icomm.assetplacement.controller
Classpublic class XMLDataLoader
InheritanceXMLDataLoader Inheritance EventDispatcher Inheritance Object
Implements IMXMLObject, IPackageObject

Language Version: ActionScript 3.0
Product Version: Asset Placement Building Block 9.5
Runtime Versions: AIR 1.0, Flash Player 9, Flash Player 10

XMLDataLoader is used to load a resource from the package definition that points to an XML data file. The XMLDataLoader is linked to an asset in the package definition through its id.

If autoLoad is true, then whenever the id property is changed, the data linked to the new id will be loaded. If autoLoad is false, then an explicit call to loadData() must be made to load the package XML resource. Once the XML data is loaded and ready to use, an XmlDataReadyEvent is dispatched.

View the examples



Public Properties
 PropertyDefined By
  autoLoad : Boolean
A flag that indictes whether content starts loading automatically when the id is set or waits for a call to the loadData() method.
XMLDataLoader
 Inheritedconstructor : Object
A reference to the class object or constructor function for a given object instance.
Object
  id : String
The id of this object, which is used to link up to the controller attribute in the assets section of the package definition file.
XMLDataLoader
  packageAttachments : IList
[read-only] A list of Attachment objects who's controller id attribute matches the id of this object.
XMLDataLoader
  packageController : Controller
[read-only] The controller object who's id matches the id of this object.
XMLDataLoader
  packageResource : Resource
[read-only] The current Resource object who's controller id attribute matches the id of this object.
XMLDataLoader
  packageResources : IList
[read-only] A list of Resource objects who's controller id attribute matches the id of this object.
XMLDataLoader
Public Methods
 MethodDefined By
  
Constructor.
XMLDataLoader
 Inherited
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
Registers an event listener object with an EventDispatcher object so that the listener receives notification of an event.
EventDispatcher
 Inherited
Dispatches an event into the event flow.
EventDispatcher
 Inherited
Checks whether the EventDispatcher object has any listeners registered for a specific type of event.
EventDispatcher
 Inherited
Indicates whether an object has a specified property defined.
Object
 Inherited
Indicates whether an instance of the Object class is in the prototype chain of the object specified as the parameter.
Object
  
This method loads the XML data associated to the id property in the package definition file.
XMLDataLoader
 Inherited
Indicates whether the specified property exists and is enumerable.
Object
 Inherited
removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
Removes a listener from the EventDispatcher object.
EventDispatcher
 Inherited
Sets the availability of a dynamic property for loop operations.
Object
 Inherited
Returns the string representation of this object, formatted according to locale-specific conventions.
Object
 Inherited
Returns the string representation of the specified object.
Object
 Inherited
Returns the primitive value of the specified object.
Object
 Inherited
Checks whether an event listener is registered with this EventDispatcher object or any of its ancestors for the specified event type.
EventDispatcher
Events
 Event Summary Defined By
 Inherited[broadcast event] Dispatched when the Flash Player or AIR application gains operating system focus and becomes active.EventDispatcher
 Inherited[broadcast event] Dispatched when the Flash Player or AIR application operating loses system focus and is becoming inactive.EventDispatcher
  Dispatched when new content is loaded after calling loadData() or when changing the id property, if autoLoad is set to true.XMLDataLoader
Property Detail

autoLoad

property
autoLoad:Boolean

Language Version: ActionScript 3.0
Product Version: Asset Placement Building Block 9.5
Runtime Versions: AIR 1.0, Flash Player 9, Flash Player 10

A flag that indictes whether content starts loading automatically when the id is set or waits for a call to the loadData() method. If true, the content loads automatically. If false, you must call the loadData() method.

The default value is true.



Implementation
    public function get autoLoad():Boolean
    public function set autoLoad(value:Boolean):void

id

property 
id:String

Language Version: ActionScript 3.0
Product Version: Asset Placement Building Block 9.5
Runtime Versions: AIR 1.0, Flash Player 9, Flash Player 10

The id of this object, which is used to link up to the controller attribute in the assets section of the package definition file.



Implementation
    public function get id():String
    public function set id(value:String):void

packageAttachments

property 
packageAttachments:IList  [read-only]

Language Version: ActionScript 3.0
Product Version: Asset Placement Building Block 9.5
Runtime Versions: AIR 1.0, Flash Player 9, Flash Player 10

A list of Attachment objects who's controller id attribute matches the id of this object.



Implementation
    public function get packageAttachments():IList

packageController

property 
packageController:Controller  [read-only]

Language Version: ActionScript 3.0
Product Version: Asset Placement Building Block 9.5
Runtime Versions: AIR 1.0, Flash Player 9, Flash Player 10

The controller object who's id matches the id of this object.



Implementation
    public function get packageController():Controller

packageResource

property 
packageResource:Resource  [read-only]

Language Version: ActionScript 3.0
Product Version: Asset Placement Building Block 9.5
Runtime Versions: AIR 1.0, Flash Player 9, Flash Player 10

The current Resource object who's controller id attribute matches the id of this object.



Implementation
    public function get packageResource():Resource

packageResources

property 
packageResources:IList  [read-only]

Language Version: ActionScript 3.0
Product Version: Asset Placement Building Block 9.5
Runtime Versions: AIR 1.0, Flash Player 9, Flash Player 10

A list of Resource objects who's controller id attribute matches the id of this object.



Implementation
    public function get packageResources():IList
Constructor Detail

XMLDataLoader

()Constructor
public function XMLDataLoader(id:String = "")

Language Version: ActionScript 3.0
Product Version: Asset Placement Building Block 9.5
Runtime Versions: AIR 1.0, Flash Player 9, Flash Player 10

Constructor.

Parameters
id:String (default = "") — Set the id property when constructing the object.
Method Detail

loadData

()method
public function loadData():void

Language Version: ActionScript 3.0
Product Version: Asset Placement Building Block 9.5
Runtime Versions: AIR 1.0, Flash Player 9, Flash Player 10

This method loads the XML data associated to the id property in the package definition file. When the data is ready for use, an xmlDataReady event is dispatched. The event contains the data.

Related API Elements

Event Detail

xmlDataReady

Event
Event Object Type: com.adobe.icomm.assetplacement.controller.XMLDataReadyEvent
property XMLDataReadyEvent.type = com.adobe.icomm.assetplacement.controller.XMLDataReadyEvent.XML_DATA_READY

Language Version: ActionScript 3.0
Product Version: Asset Placement Building Block 9.5
Runtime Versions: AIR 1.0, Flash Player 9, Flash Player 10

Dispatched when new content is loaded after calling loadData() or when changing the id property, if autoLoad is set to true.

A value that represents the Event name.
This class can be used in ActionScript as follows:
     
     public function foo():void
     {
          var xmlDataLoader:XMLDataLoader = new XMLDataLoader();
          xmlDataLoader.autoLoad = false;
          xmlDataLoader.id = "data";
     
          xmlDataLoader.addEventListener(XMLDataReadyEvent.XML_DATA_READY, xmlDataReadyHandler);
          xmlDataLoader.loadData(); 
     }
     
     private function xmlDataReadyHandler(event:XMLDataReadyEvent):void
     {
          var root:XML = event.data;
     
          // Do stuff with the XML...
     }
     
     

The XMLDataLoader can also be used in MXML:

     
     <mx:Module xmlns:mx="http://www.adobe.com/2006/mxml" 
                xmlns:ap="http://ns.adobe.com/livecycle/icomm/assetplacement">
     
             <mx:Script>
                 <![CDATA[
                     // Called when XMLDataLoader loads data
                     private function onXMLDataReady(event:XMLDataReadyEvent):void
                  {
                      var info:XML = event.data;
                      StatementDataText.data = info.PhoneBill;
                  }    
             ]]>
          </mx:Script>
     
          <ap:XMLDataLoader id="data" xmlDataReady="onXMLDataReady(event)"/>
     
     </mx:Module>