For loop + preloader

peepz,

i have a script that duplicates mc dynamicly, and i have a mc preloader prototype, now i want to let the for loop stops looping if the image isn’t loaded. and it have to load after each other, just like: 1,2,3,4,5 and so on… (the backgrounds wich are duplicated in the same clip are also visible before the image is preloaded, i want that there is only one visible in wich the image is currently loading!)

the following small code is within a for loop for preloading images(works fine)!:


myMCL.loadClip("[images/photo_gallery/thumbs/"+ap[z].photo+".jpg](http://www.inlusion.com/temp/rockit/images/photo_gallery/thumbs/)", this["mcPhotoHolder"+z].mcThumb);
  myMCL.addListener(myListener);

total for loop code:


function showArray()
{
 
 nbrCols = 4;
 // Space between objects [horizontal, vertical]
 rraGutter = [1, 12];
 for (var z = 0; z<ap.length; z++)
 {
  mcPhotoHolder.duplicateMovieClip("mcPhotoHolder"+z, z);
  this["mcPhotoHolder"+z]._x = (this["mcPhotoHolder"+z]._width+rraGutter[0])*(z%nbrCols);
  this["mcPhotoHolder"+z]._y = (this["mcPhotoHolder"+z]._height+rraGutter[1])*Math.floor(z/nbrCols);
  //define click actions
  this["mcPhotoHolder"+z].large = ap[z].photo;
  
  
  myMCL.loadClip("[images/photo_gallery/thumbs/"+ap[z].photo+".jpg](http://www.inlusion.com/temp/rockit/images/photo_gallery/thumbs/)", this["mcPhotoHolder"+z].mcThumb);
  myMCL.addListener(myListener);

 }
}
//movieClipLoader----------------------------------------------------------------++
myMCL = new MovieClipLoader();
myListener = new Object();
myListener.onLoadStart = function(targetMC)
{    
 totalBytes = targetMC.getBytesTotal();
 trace("The total bytes of img1 is "+totalBytes);
}
myListener.onLoadProgress = function (targetMC, bytesLoaded, bytesTotal)
{ 
 percentBytes = Math.round((bytesLoaded/bytesTotal)*100);
 trace(percentBytes+" %"); 
 _root.bar._xscale = percentBytes;
}
myListener.onLoadComplete = function(targetMC)
{   
    
 targetMC._alpha = 0;
 targetMC.onEnterFrame = function()
 {
  //start an onenterframe loop        
  if (targetMC._alpha <= 99)
  {
   targetMC._alpha += 17;
  } 
  else if(targetMC >=99)
  {           
   targetMC._alpha = 100;
   delete targetMC.onEnterFrame;
   //delete the loop
  }    
 }
}
//movieClipLoader----------------------------------------------------------------++