XML gallery sorting with Loader class

Hey guys

I’m reasonably new to AS3 having made the leap from Flash 8 to CS4 in a single bound. I’ve been doing okay, but I’ve stumbled across a bit of an issue:

I’m using an XML file to load a gallery of images and information, where a node typically looks like this:


 <project>
  <image>1.jpg</image> 
  <link>gallery-1</link> 
- <title>
- <![CDATA[ This is image number 1]]> 
  </title>
- <info>
- <![CDATA[ Lorem ipsum dolor sit amet, consectetaur adipisicing elit. ]]> 
  </info>
  </project>
- <project>

In AS, once my XML has been parsed, it runs this function:

[AS]
var projectTitles:Array = new Array();

function createProjectClips(list:XMLList):void {
projectsLength = list.length();

for (var i:Number = 0; i < projectsLength; i++) {

var image:String = list.image*;
var title:String = list.title*;
var link:String = list.link*;
var desc:String = list.info*;

projectTitles* = image;

var thumbLoader:Loader = new Loader();
thumbLoader.load(new URLRequest(image));
thumbLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,createProjectThumb,false,0,true);
}
}
var imageCount:int = 0;

function createProjectThumb(evt:Event):void {
var bmp:Bitmap = Bitmap(evt.target.content);
addChild(bmp);

imageCount++;
bmp.x = imageCount * 240;
}
[/AS]

This all works fine; I need all of these thumbs loaded and parsed at the same time to show the full gallery. The issue is that, as the images are of varying file sizes they don’t load in sequence, and because I can’t pass additional parameters through the eventListener, I’ve apparently got no way to organise the images on screen. So, my images on screen might be in the sequence 1.jpg, 4.jpg, 3.jpg, 2.jpg, but my projectTitles array will say Image 1, Image 2, Image 3, Image 4.

Does anyone have any tips on how to organise my gallery properly? T’would be greatly appreciated.