Loading thumbs 1 by 1

Hi

I’m trying to make a code to load my thumbs 1 by 1. It should start to load the next thumb, once it’s ready with the previous one.

I’m reading my thumbs out of an xml. It seems like it’s placing them randomly.

Here is what I have so far.
Can somebody help me out with this.

var numPics = galleryList.length;

function placeThumbs() {
	var i = 0;
	while (i < numPics) {
		_root.attachMovie("holder", "holderImg"+i, 10+i);
		_root["holderImg"+i].attachMovie("holder", "holder", 10);
		_root["holderImg"+i].holder.loadMovie("pics/" + galleryList*.tmb);
		_root["holderImg"+i]._x = i * 50;
		_root["holderImg"+i].onEnterFrame = function() {
			this.holder.total = this.holder.getBytesTotal();
			this.holder.loaded = this.holder.getBytesLoaded();
			this.holder.percent = Math.floor(this.holder.loaded/this.holder.total);
			imageName.text = "image " + i;
			imagePercent.text = this.holder.percent;
			if (this.holder.total > 5) {
				if (this.holder.loaded >= this.holder.total) {
					delete this.onEnterFrame;
					//more actions
				}
			}
		}
		i++;
	}
}

placeThumbs();