Problem distributing thumbnails in gallery

I am using a slightly modified version of http://www.kirupa.com/developer/mx2004/thumbnails5.htm. The problem I am having is that my thumbs get arranged out of order because they aren’t all the same width. The way the code from the tutorial works is it reads the width of the image onLoad, then multiplies it by the number image it is.

target_mc._x = 10 + (eval("thumbnail_mc.t" + k)._width + 5) * k;

This doesn’t work, cuz some images are much thinner, so the thin images end up way too far left.

My method was to define a starting width (curWidth), then set the position of my thumb by using that value. once that is postioned, add the width of the image to curWidth plus a space. Reapeat for each image.

curWidth = 10;

function thumbnails_fn(k) {
    thumbnail_mc.createEmptyMovieClip("t" + k, thumbnail_mc.getNextHighestDepth());
    tlistener = new Object();
    tlistener.onLoadInit = function (target_mc) {
        //target_mc._x = 10 + (eval("thumbnail_mc.t" + k)._width + 5) * k;//ORIGINAL CODE
        target_mc._x = curWidth;
        curWidth = curWidth+target_mc._width+10;
        
        target_mc.pictureValue = k;
    };
    image_mcl = new MovieClipLoader();
    image_mcl.addListener(tlistener);
    image_mcl.loadClip(thumbnails[k], "thumbnail_mc.t" + k);
}

The problem with this is it puts the image out of order. In fact, it orders them based on the order they download. I understand why (cuz of onLoadInit) but I am not sure what to do about it.

Any ideas?