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:
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);
}
}
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
<categories>
<category categoryTitle="People" id="0" />
<category categoryTitle="Nature" id="1" />
<category categoryTitle="Buildings" id="2" />
</categories>
category1.xml (number varies)
<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).
Any ideas on how to achieve this?