# OOP problems

**URL:** <https://forum.kirupa.com/t/oop-problems/81950>\
**Category:** flash\
**Created:** [March 6, 2005, 3:25pm UTC](https://forum.kirupa.com/t/oop-problems/81950 "2005-03-06T15:25:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Flashmatazz](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/flashmatazz/32/140_2.png) [@Flashmatazz](https://forum.kirupa.com/u/Flashmatazz)\
**Post date:** [March 6, 2005, 3:25pm UTC](https://forum.kirupa.com/t/oop-problems/81950/1 "2005-03-06T15:25:44Z")

</div>

I’m trying to learn OOP but having some problems.

I have this class (just an example)

```auto

class MyClass
{	
	function loadCategories () : Array
	{
		// create a reference to this class instance to use within the XML onload handler
		var host = this;
		var parsedcategories:Array = new Array();
		var categories:XML = new XML ();
		categories.ignoreWhite = true;
		categories.onLoad = function (success : Boolean)
		{
			host.removeLoader ();
			if (success)
			{
				parsedCategories = host.parseCategories (this);
			}
		}
		categories.load ("test_categories.xml");
		return parsedCategories;
	}
	function parseCategories (categories_xml : XML):Array
	{
		var category_array : Array = new Array ();
		// do something
		// return category_array 
	}
}

```

Now when I call this like this:

```auto

var myClass:MyClass= new MyClass();
var categories:Array = myClass.loadCategories();
trace ("categories: " + categories);

```

then nothing is traced, because when the ‘return parsedCategories’ statement is executed the XML isn’t loaded yet.  
What would be the best way to set up a class method that loads external data and returns it when loading is finished?

Cheers.
