# XML object onLoad scope problem

**URL:** <https://forum.kirupa.com/t/xml-object-onload-scope-problem/266615>\
**Category:** flash\
**Created:** [July 22, 2008, 5:44pm UTC](https://forum.kirupa.com/t/xml-object-onload-scope-problem/266615 "2008-07-22T17:44:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![the\_lar](https://avatars.discourse-cdn.com/v4/letter/t/90ced4/32.png) [@the\_lar](https://forum.kirupa.com/u/the_lar)\
**Post date:** [July 22, 2008, 5:44pm UTC](https://forum.kirupa.com/t/xml-object-onload-scope-problem/266615/1 "2008-07-22T17:44:43Z")

</div>

Hi All,

I’ve got a very frustrating scope issue here, probably quite simple, but it’s got me stumped.

I have a class which loads up some XML into an XML object, on loading the XML I want to fire a function in the class. Here is my code:

```auto

class classes.availability extends MovieClip {
    var my_xml:XML;
    var feedURL:String;
    
    private function init(){
        trace("Initialising office availability");
        feedURL = "http://addressofmyxmlhere.xml";
        my_xml = new XML();
        my_xml.onLoad = function(success){
            trace("loaded XML");
            processXML(this);
        };
        my_xml.ignoreWhite = true;
        my_xml.load(feedURL);
    }

    public function processXML(xml){
        trace("processing XML");
    }
}

```

I’m obviously doing something wrong because processXML is not happening. I have tried calling \_root.instance.processXML(this) in the onLoad function, and that works, but I can’t use \_root because I don’t necessarily know where this is going to be used.

Any thoughts?

Many thanks  
Kevin
