# XML & OO, problems with onLoad

**URL:** <https://forum.kirupa.com/t/xml-oo-problems-with-onload/219640>\
**Category:** flash\
**Created:** [March 19, 2007, 12:02am UTC](https://forum.kirupa.com/t/xml-oo-problems-with-onload/219640 "2007-03-19T00:02:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![keesj](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/keesj/32/2090_2.png) [@keesj](https://forum.kirupa.com/u/keesj)\
**Post date:** [March 19, 2007, 12:02am UTC](https://forum.kirupa.com/t/xml-oo-problems-with-onload/219640/1 "2007-03-19T00:02:48Z")

</div>

I’m creating a XML-powered photo gallery with categories and I’m having some problems loading all this information into flash. I created the following classes:

```auto

class Category
{
	public var id:Number;
	public var categoryTitle:String;
	public var photos:Array;

	public function Category(i:Number, t:String)
	{
		id = i;
		categoryTitle = t;
		photos = new Array();
	}
	
	public function addPhoto(p:Photo)
	{
		photos.push(p);
	}
}

```

```auto

class Photo
{	
	public var full:String;
	public var thumbnail:String;

	public function Photo(f:String, t:String)
	{
		full = f;
		thumbnail = t;
	}	
}

```

My XML files look like this:

**categories.xml**

```auto

<categories>
	<category categoryTitle="People" id="0" />
	<category categoryTitle="Nature" id="1" />
	<category categoryTitle="Buildings" id="2" />
</categories>

```

**category1.xml** (number varies)

```auto

<photos>
	<photo full="photos/tree.jpg" thumbnail="photos/th_tree.jpg" />
	<photo full="photos/rabbit.jpg" thumbnail="photos/th_rabbit.jpg" />
	<photo full="photos/water.jpg" thumbnail="photos/th_water.jpg" />
	<photo full="photos/sun.jpg" thumbnail="photos/th_sun.jpg" />
</photos >

```

I tried creating an array called _categories_ with all the categories which contain all the photos but I haven’t been able to get it to work properly. Everytime the code was run before the XML was loaded… and when using onLoad I had to nest a couple of them which became a big mess. I’ve also tried going fully Object Oriented using Createage’s XMLLoader ([http://www.createage.com/blog/?p=104](http://www.createage.com/blog/?p=104)).

**Any ideas on how to achieve this?**
