# How to load multiple XML files and know when all loaded

**URL:** <https://forum.kirupa.com/t/how-to-load-multiple-xml-files-and-know-when-all-loaded/286811>\
**Category:** flash\
**Created:** [April 21, 2009, 11:27am UTC](https://forum.kirupa.com/t/how-to-load-multiple-xml-files-and-know-when-all-loaded/286811 "2009-04-21T11:27:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jaxz](https://avatars.discourse-cdn.com/v4/letter/j/c6cbf5/32.png) [@jaxz](https://forum.kirupa.com/u/jaxz)\
**Post date:** [April 21, 2009, 11:27am UTC](https://forum.kirupa.com/t/how-to-load-multiple-xml-files-and-know-when-all-loaded/286811/1 "2009-04-21T11:27:30Z")

</div>

**How to load multiple XML files and know when all loaded**

I load several XML files at the start of my AS code.  
Using addEventlistener/Event.Complete for each URLloader I call upon functions to get data from the respective XML files.

Like this:

// Loads themes from XML file themes.xml  
themeLoader.addEventListener(Event.COMPLETE, getThemes);  
themeLoader.load(new URLRequest(“themes.xml”));

// Loads cats from XML file cats.xml  
catloader.addEventListener(Event.COMPLETE, getCats);  
catloader.load(new URLRequest(“cats.xml”));

function getThemes(e:Event):void  
{  
themes\_xml = new XML(e.target.data);  
themelist = themes\_xml.theme;  
N\_themes = themelist.length();  
MainShow();  
}

function getCats(e:Event):void  
{  
cats\_xml = new XML(e.target.data);  
catlist = cats\_xml.cat;  
N\_cats = catlist.length();  
nextCat();  
}

In those functions I call other functions to start my application.

The problem is that if some XML file (like cats.xml above) has not been loaded before I call MainShow(), I get errors since MainShow() also uses data from the cats.xml. Thus I would need to somehow wait for all my XML files to be loaded before I start up my application.

How can I do this in a convenient way?

please advice!

/jaxz
