# AS3 class to access external XML... help

**URL:** <https://forum.kirupa.com/t/as3-class-to-access-external-xml-help/293666>\
**Category:** flash\
**Created:** [August 1, 2009, 2:54am UTC](https://forum.kirupa.com/t/as3-class-to-access-external-xml-help/293666 "2009-08-01T02:54:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![noverflow](https://avatars.discourse-cdn.com/v4/letter/n/e56c9b/32.png) [@noverflow](https://forum.kirupa.com/u/noverflow)\
**Post date:** [August 1, 2009, 2:54am UTC](https://forum.kirupa.com/t/as3-class-to-access-external-xml-help/293666/1 "2009-08-01T02:54:31Z")

</div>

So I have a class that reads from an external XML file, and it works great. (uses URLRequest and complete event listener)

I have functions in it to read certain parts of the file.

Im trying to create a new instance of that class in my document class. I am able to do this, BUT because the XML class loads the file, and uses a complete event listener to load it, anything I try to access (var or function) come up blank because it fires before the file is done being loaded.

Id like to be able to do something like this.

```auto
var prefs:XMLClass = new XMLClass();

var localcolor:uint = prefs.color; (access the public variable color)
or
var localcolor:uint = prefs.getColor();

```

If I access the var, it is 0 (unset), and if I call the function, it says “Cannot access a property or method of a null object reference” because it hasn’t loaded yet.

What am I doing wrong?
