# XMLLoader Class - Accessing data

**URL:** https://forum.kirupa.com/t/xmlloader-class-accessing-data/249324
**Category:** flash
**Created:** [January 17, 2008, 3:57pm UTC](https://forum.kirupa.com/t/xmlloader-class-accessing-data/249324 "2008-01-17T15:57:43Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![benny\_hill](https://avatars.discourse-cdn.com/v4/letter/b/b5e925/32.png) [@benny\_hill](https://forum.kirupa.com/u/benny_hill)
#### Post date: [January 17, 2008, 3:57pm UTC](https://forum.kirupa.com/t/xmlloader-class-accessing-data/249324/1 "2008-01-17T15:57:43Z")

</div>

I made this simple xml loader class:

```auto

package 
{
 import flash.net.*;
 import flash.display.Sprite;
 import flash.events.*;
 public class XMLLoader extends Sprite
 {
  private var xml:XML;
  private var xmlLoader:URLLoader = new URLLoader();
  public var xmlList:XMLList;
  
  public function XMLLoader([url:String](http://www.kirupa.com/forum/String))
  {
   xmlLoader.load(new URLRequest(url));
   xmlLoader.addEventListener(Event.COMPLETE, onComplete);
  }
  
  private function onComplete(event:Event):void
  {
   xml = XML(event.target.data);
   xmlList = xml.children();
  }
 }
}

```

Then in the main fla, after I import the class I write this:

```auto

var myXML:XMLLoader = new XMLLoader("file.xml");
trace(myXML.xmlList);

```

the trace statement returns **null** because it is being called before the xml file is finished loading. When I put the trace call in the class file in the onComplete handler it works fine.

My question is this. How do I properly access the xml file after it is completely loaded from the main fla or another class? How do classes know when the files from other classes are done loading and ready to use?
