- Top
- Summary
- Constructors
- Class properties
- Instance properties
- Class methods
- Instance methods
- Event handlers
XMLLoader
| Kind of class: | class |
|---|---|
| Inherits from: | Dispatcher |
| Author: | Martijn de Visser |
| Classpath: | org.asapframework.util.xml.XMLLoader |
| File last modified: | Sunday, 05 November 2006, 11:27:56 |
Loads XML files. For your convenience, this class won't allow more than 3 simultaneous XML.load calls, to prevent this Flash Player bug: http://www.macromedia.com/go/c0da292b from occuring.
More than three simulaneous calls are placed in a queue and loaded sequentially.
More than three simulaneous calls are placed in a queue and loaded sequentially.
Usage:
-
var myXMLLoader:XMLLoader = XMLLoader.getInstance(); myXMLLoader.addEventListener( XMLEvent.ON_LOADED, this ); myXMLLoader.load("../xml/myfile.xml", "myFile");
In your listening class ('this' in example):public function onXMLLoaded (e:XMLEvent) : Void { // handle result }
Summary
Constructor
Class properties
- mCurrentCalls : Number
- of XMLWorker objects
- MAX_CALLS : Number
- ERROR_CDATA_TERMINATION : Number
- ERROR_XML_TERMINATION : Number
- ERROR_DOCTYPE_TERMINATION : Number
- ERROR_COMMENT_TERMINATION : Number
- ERROR_ELEMENT_MALFORMED : Number
- ERROR_OUT_OF_MEMORY : Number
- ERROR_ATTRIBUTE_TERMINATION : Number
- ERROR_STARTTAG_WITHOUT_ENDTAG : Number
- ERROR_ENDTAG_WITHOUT_STARTTAG : Number
- ERROR_TIMEOUT : Number
- instance : XMLLoader
Class methods
- XMLError (inError:Number) : String
- Converts an XML error to a string.
- getInstance : XMLLoader
- Returns reference to singleton instance of XMLLoader.
Instance methods
- load (inURL:String, inName:String, inNoCache:Boolean, inTimeOut:Number) : Boolean
- Loads an XML file.
- startLoading (inWorker:XMLWorker) : Boolean
- Tries to start loading the file.
- loadNext : Void
- Loads the next file in the queue that's not being loaded yet.
- removeWorker (inWorker:XMLWorker) : Void
- Removes a wrapper from the queue and breaks listener relation.
- toString : String
Event handlers
- onXMLLoaded (e:XMLWorkerEvent) : Void
- Callback from XMLWorker
- onXMLTimeout (e:XMLWorkerEvent) : Void
- Triggered if no response from server was received within timeout interval.
Constructor
XMLLoader
function XMLLoader (
)
Private constructor, use getInstance to refer to the singleton instance.
Class properties
ERROR_ATTRIBUTE_TERMINATION
static ERROR_ATTRIBUTE_TERMINATION:Number = -8
(read)
ERROR_CDATA_TERMINATION
static ERROR_CDATA_TERMINATION:Number = -2
(read)
ERROR_COMMENT_TERMINATION
static ERROR_COMMENT_TERMINATION:Number = -5
(read)
ERROR_DOCTYPE_TERMINATION
static ERROR_DOCTYPE_TERMINATION:Number = -4
(read)
ERROR_ELEMENT_MALFORMED
static ERROR_ELEMENT_MALFORMED:Number = -6
(read)
ERROR_ENDTAG_WITHOUT_STARTTAG
static ERROR_ENDTAG_WITHOUT_STARTTAG:Number = -10
(read)
ERROR_OUT_OF_MEMORY
static ERROR_OUT_OF_MEMORY:Number = -7
(read)
ERROR_STARTTAG_WITHOUT_ENDTAG
static ERROR_STARTTAG_WITHOUT_ENDTAG:Number = -9
(read)
ERROR_TIMEOUT
static ERROR_TIMEOUT:Number = -100
(read)
ERROR_XML_TERMINATION
static ERROR_XML_TERMINATION:Number = -3
(read)
instance
MAX_CALLS
static private MAX_CALLS:Number = 3
(read)
Instance properties
mWorkerQueue
private mWorkerQueue:Array
(read)
Class methods
getInstance
Returns reference to singleton instance of XMLLoader.
XMLError
static private function XMLError (
inError:Number) : String
Converts an XML error to a string.
Instance methods
load
function load (
inURL:String,
inName:String,
inNoCache:Boolean,
inTimeOut:Number) : Boolean
Loads an XML file.
Parameters:
inURL :
The URL of the xml file
inName :
Unique identifier; this name will also be used in callback events when file was loaded or when an error was encountered.
inNoCache:
If set to true, the xml file will always be fetched from the server by appending a timestamp to the call, thus circumventing the local browser cache.
inTimeOut:
Set value to specify time to wait (in milliseconds) for a server response (excluding the download time of the actual XML data itself). Defaults to 10 seconds if no value is specified. Set to '0' to disable timeout.
Returns:
- Boolean, false if XML document couldn't be added (because name already exists is list).
loadNext
private function loadNext (
) : Void
Loads the next file in the queue that's not being loaded yet.
Events broadcasted to listeners:
- XMLEvent with type:
ON_ALL_LOADED- for 'onXMLTimeout' event
removeWorker
Removes a wrapper from the queue and breaks listener relation.
startLoading
Tries to start loading the file.
Parameters:
inWorker:
XMLWorker
Returns:
- Boolean indicating if we could start or not.
toString
function toString (
) : String
Event handlers
onXMLLoaded
Callback from XMLWorker
onXMLTimeout
Triggered if no response from server was received within timeout interval.