# Using XML data in main fla's array

**URL:** https://forum.kirupa.com/t/using-xml-data-in-main-flas-array/324241
**Category:** flash
**Created:** [August 10, 2011, 7:15am UTC](https://forum.kirupa.com/t/using-xml-data-in-main-flas-array/324241 "2011-08-10T07:15:37Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![lNotMyFaultl](https://avatars.discourse-cdn.com/v4/letter/l/74df32/32.png) [@lNotMyFaultl](https://forum.kirupa.com/u/lNotMyFaultl)
#### Post date: [August 10, 2011, 7:15am UTC](https://forum.kirupa.com/t/using-xml-data-in-main-flas-array/324241/1 "2011-08-10T07:15:37Z")

</div>

Hi people,  
I’m having some trouble trying to use the xml’s array to store into the main fla file’s array so that i can randomize the array for use. Any idea how I could extract the data out from the xmlloader?

Here is the code for the main fla file:  
Code:

```auto

     var xmlLoader: URLLoader = new URLLoader();
		var xmlData: XML = new XML();
		var factsArrays: Array = new Array();

		function xmlTutorial()
		{
			xmlLoader.addEventListener(Event.COMPLETE, LoadXML);
			xmlLoader.load(new URLRequest("FactText.xml"));
		}

		function LoadXML(e:Event):void
		{
			trace("XML File Loaded");
			xmlData = new XML(e.target.data);
			for (var i in xmlData.item) {
				factsArrays.push({text:xmlData.item*.text, url:xmlData.item*.url});
			}
			trace(factsArrays[0].text);
			trace(factsArrays[1].text);
		}

                var newFactArray:Array = new Array();

                function startGame():void{//we'll run this function every time a new level begins
		
	        for(var i:int=0;i<enemyArray[currentLvl-1].length;i++){
		    if(enemyArray[currentLvl-1]* != 0){
			enemiesLeft ++;
		}
	                 }
	                 this.xmlTutorial();
	                 factRandomArray();
	                 trace(newFactArray[0].toString());
	                 trace(newFactArray[1].toString());
	                 trace(newFactArray[2].toString());
	                 trace(newFactArray[3].toString());
	                 trace(newFactArray[4].toString());
                         }

			
                //randomize the facts
                function factRandomArray():Array {
       
	            while(factArray.length > 0)
	            {
    	            var obj:Array = factArray.splice(Math.floor(Math.random()*factArray.length), 1);
                    newFactArray.push(obj[0]);
                    }
                        return newFactArray;
                }

```

Thanks in advance
