Our XML file will contain the URLs of our external photo's

Structure:

Our XML structure is actually pretty simple we have a root tag which named images and the sub items are named img and each one will contain the url to the images we need to load.

<images>
<img> url1 </img>
<img> url2 </img>
</images>

To load an external file in AS3 we need to create a URLLoader object and a URLRequest object. Our xml file is named “data.xml” and the instance of the URLLoader object is called xmlLoader then all we have to do is to use the load method with the URLRequest object to load the xml file.

xmlLoader.load(new URLRequest("data.xml"));

What we need after this is to assign a load complete event which will be triggered after the loading of the xml has done.

xmlLoader.addEventListener(Event.COMPLETE,parseXML);

The parseXML is the method which will be executed asynchronously after the xml loading is done.

The call back function is in our public class that is assigned to our stage movie.


Private function parseXML(event){

//the event object contain our xml data in a string format, we will create our xml object from it

myXML:XML=new XML(event.target.data);

}

Event.target represent the URLLoader Object and the data proporety contain the loaded file data in a string fromat.

So after the loading let's do the parsing and the menu generation.