Loaded Clips Not Showing Up Until Second Attempt

This has happened to me multiple times and I’m curious what causes it to happen.

This is my current code.



function preloadThumbs(num:String):Void {
    var horizontal_spacing:Number = 40;
    var target1_mc:MovieClip = eval("thumb_container_mc.icon"+thumbsLoaded+"_mc");
    if (target1_mc._name == undefined) {
        var target_mc:MovieClip = thumb_container_mc.attachMovie("icon2_mc", "icon"+thumbsLoaded+"_mc", thumb_container_mc.getNextHighestDepth());
        target_mc.setToDrag = false;
        target_mc.icon_holder_mc.loadMovie(assetts_array[num][1][thumbsLoaded]);
        target_mc._alpha = 0;
    } else {
        target1_mc._alpha = 0;
        target1_mc.pre_h = target1_mc._height;
        target1_mc.pre_w = target1_mc._width;
        var new_dimen:String = resizeClip(target1_mc._height, target1_mc._width);
        var a:Array = new_dimen.split("-");
        target1_mc.invisible_btn._height = target1_mc._height=a[0];
        target1_mc.invisible_btn._width = target1_mc._width=a[1];
        var total:Number = target1_mc.icon_holder_mc.getBytesTotal();
        var loaded:Number = target1_mc.icon_holder_mc.getBytesLoaded();
       
        var a:String = String(String(target1_mc).substr(Number(String(target1_mc).indexOf('icon') + 4), 1));
        var b:Number = String(target1_mc.icon_holder_mc._url).indexOf(should_be_loaded[a]);
           
        if (b == -1) {
            target1_mc.icon_holder_mc.loadMovie(should_be_loaded[a]);
        }
           
        if (total == loaded && total>66) {
            target1_mc.icon_holder_mc.swapDepths(target1_mc.getNextHighestDepth());
            target1_mc.icon_holder_mc._x = -(target1_mc._x/2);
            target1_mc.icon_holder_mc._y = -(target1_mc._y/2);
            target1_mc.swapDepths(thumb_container_mc.getNextHighestDepth());
            thumbsLoaded++;
            target1_mc._x = cur_icon_x;
            cur_icon_x += target1_mc._width+horizontal_spacing;
            target1_mc._alpha = 100;
            if (thumbsToLoad<=thumbsLoaded) {
                clearInterval(preInt);
                cur_icon_x = 0;
                loading_assetts_mc._alpha = 0;
            }
        }
    }
}


function loadClips(clip_set:Number):Void {
    clearInterval(preInt);
    thumbsLoaded = cur_icon_x=0;
    for (var i:Number = 0; i<thumbsToLoad; i++) {
        var target_mc:MovieClip = eval("thumb_container_mc.icon"+i+"_mc");
        target_mc.removeMovieClip();
    }
    thumbsToLoad = assetts_array[clip_set][1].length;
   
    should_be_loaded = new Array();
   
    for (var i:Number = 0; i < assetts_array[clip_set][1].length; i++) {
        should_be_loaded.push(assetts_array[clip_set][1]*);
    }
    clearInterval(preInt);
    preInt = setInterval(preloadThumbs, 83, clip_set);
}


I can try to find a simpler example if it would help.

Essentially what happens is I dynamically attach movie clips to a container clip, then one by one load external clips into them from an array created through xml. My problem is the clips don’t show up the first time, they will show up the second time I click the button though.

I don’t understand why that is. How it can show the second time, but not the first, with the exact same code being executed.

Here is the current working example if that helps:

http://www.thedesignequation.com/temp/

Any help would be GREATLY appreciated.