Another way that you can use to load xml data in Flex is by using the URLLoader class.
To use the URLLoader class you must:
- define a new
URLLoader:
var loader:URLLoader = new URLLoader(); - add an event listener to the newly created
URLLoader:
loader.addEventListener(Event.COMPLETE, xmlLoaded); - call the
loadmethod of the newly createdURLLoader:
loader.load(new URLRequest(url)); - define the
xmlLoadedfunction that will parse the loaded data
The load() method of the URLLoader class takes a URLRequest parameter.
In this example I created a new URLRequest and in the URLRequest’s constructor I used the url parameter. instead of url I could used directly “xmlFile.xml” and I would have get the same result.