# Problem with OO

**URL:** <https://forum.kirupa.com/t/problem-with-oo/130686>\
**Category:** Uncategorized\
**Created:** [December 7, 2004, 4:43pm UTC](https://forum.kirupa.com/t/problem-with-oo/130686 "2004-12-07T16:43:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![lskywalkr](https://avatars.discourse-cdn.com/v4/letter/l/d9b06d/32.png) [@lskywalkr](https://forum.kirupa.com/u/lskywalkr)\
**Post date:** [December 7, 2004, 4:43pm UTC](https://forum.kirupa.com/t/problem-with-oo/130686/1 "2004-12-07T16:43:35Z")

</div>

Hey all,

I’ve got a problem… here’s an example script:

```auto

class Example {
		var xmlLoader;
		function Example (){
				this.xmlLoader = new XML();
				this.xmlLoader.onLoad = function(){
						wannaCallThis();
				}
		}
 
		function wannaCallThis(){
				trace('yay');
		}
 
		function loadTheXML(addy:String){
				xmlLoader.load(addy);
		}
}

```

Ok, so here’s the problem. What happens in the above, is that I call ‘loadTheXML()’, it loads the xml file into xmlLoader and then runs the event handler ‘onLoad’. My problem is here: once I get into the event handler ‘this’ refers to xmlLoader, not the class. Therefore, I have no way of calling wannaCallThis(). How do I call a member function of the class from inside the eventHandler?

Hope my question was clear. Thanks in advance!
