XmlLoad
| Kind of class: | class |
|---|---|
| Inherits from: | DataLoad < BytesLoad < RetryableLoad < Load < EventDispatcher < CoreObject |
| Version: | 01/26/07 |
| Author: | Aaron Clinger |
| Classpath: | org.casaframework.load.data.xml.XmlLoad |
| File last modified: | Monday, 29 January 2007, 09:36:24 |
Creates an easy way to load or send and load XML.
Since:
Flash Player 7
Example:
To load data:
To send and load data:
To extend the XmlLoad class to parse and send
function onDataLoad(sender:XmlLoad):Void { trace(this.myXmlLoad.getXml().firstChild); } var myXmlLoad:XmlLoad = new XmlLoad("http://example.com/data.xml"); this.myXmlLoad.addEventObserver(this, XmlLoad.EVENT_LOAD_COMPLETE, "onDataLoad"); this.myXmlLoad.start();
To send and load data:
function onDataLoad(sender:XmlLoad):Void { trace(this.myXmlLoad.getXml().firstChild); } var myXmlSend:CoreXml = new CoreXml("<login><info user=\"CASA\" password=\"fr@m3w0rk\" /></login>"); var myXmlLoad:XmlLoad = new XmlLoad("http://example.com/login.php"); this.myXmlLoad.addEventObserver(this, XmlLoad.EVENT_LOAD_COMPLETE, "onDataLoad"); this.myXmlLoad.setXml(this.myXmlSend); this.myXmlLoad.start();
To extend the XmlLoad class to parse and send
"onParsed" event:import org.casaframework.load.data.xml.XmlLoad; class com.package.MyClass extends XmlLoad { public function MyClass(xmlPath:String) { super(xmlPath); } public function parse():Void { var myXml:CoreXml = this.getXml(); for (var i:String in myXml.firstChild.childNodes) { // etc... } this.$parsed(); // Dispataches "onParsed" event } }
Usage note:
Class must be extended to trigger/send
"onParsed" event.See also:
Events broadcast to listeners:
onParsing = function (sender_xml:XmlLoad) {} onParseError = function (sender_xml:XmlLoad, errorStatus:Number) {} onParsed = function (sender_xml:XmlLoad) {} Summary
Constructor
Class properties
Class properties inherited from BytesLoad
Class properties inherited from RetryableLoad
Class properties inherited from Load
Instance properties
Instance properties inherited from DataLoad
Instance properties inherited from BytesLoad
Instance properties inherited from RetryableLoad
Instance properties inherited from Load
Instance properties inherited from EventDispatcher
Instance properties inherited from CoreObject
Instance methods
Instance methods inherited from DataLoad
Instance methods inherited from BytesLoad
Instance methods inherited from RetryableLoad
Instance methods inherited from Load
Instance methods inherited from EventDispatcher
Instance methods inherited from CoreObject
Constructor
XmlLoad
function XmlLoad (
xmlPath:String)
Defines file and location of load triggered by start.
Parameters:
path:
The absolute or relative URL of the XML to be loaded.
Class properties
EVENT_PARSE_ERROR
static EVENT_PARSE_ERROR:String = 'onParseError'
(read,write)
EVENT_PARSED
static EVENT_PARSED:String = 'onParsed'
(read,write)
EVENT_PARSING
static EVENT_PARSING:String = 'onParsing'
(read,write)
Instance methods
parse
function parse (
) : Void
This function needs to be overwritten by a subclass.
Usage note:
After the subclass file is done parsing call
private function $parsed() in order to broadcast the 'onParsed' event to listeners.setXml
function setXml (
xml:CoreXml) : Void
Sets XML to be sent to the server along with the XML request.
Parameters:
xml:
The XML object to send.