My problem is that I can't figure out how to decouple the loader from this loadNewRow function. Ideally, I'd like to figure out how to load all the swf's give them dynamic names... like thmb1loaded, thmb2loaded, thmb3loaded.. push into an a ("loaded") array and then have that be used to build the grid.
Right now, its loading them every time the loadnewrow function fires. I'm sure its a simple matter of iterating a .name within a contentloaderinfo .onComplete when each swf is loaded... anyhelp would be appreciated this has been driving me crazy last couple of days..
var filePaths:Array=["thmb1.swf","thmb2.swf","thmb3.swf","thmb4.swf", "thmb5.swf", "thmb6.swf",
"thmb7.swf","thmb8.swf", "thmb9.swf", "thmb10.swf", "thmb11.swf" ];
function loadImages3(event:MouseEvent):void {
TweenLite.to(pic, 8, {alpha:0, ease:Expo.easeInOut});// dim image container
trace("loadImages3 fired ---------------------------------------------------------")
unloadImages3resize(); loadImages3Flag=true;
var randomScale:Number = .3 + Math.random();trace("in loadimages3 function randomScale is now.. " + randomScale);
var stage_w=stage.stageWidth;trace("in loadimages3 function stage_w is = " + stage_w);
var stage_h=stage.stageHeight;trace("in loadimages3 function stage_h is = " + stage_h);
var thumbWidth:Number=240;var thumbHeight:Number=155;//var randomScale:Number=.45;
var scaleThumbs:Number=randomScale;
var finalRandomScaledWidth:Number=thumbWidth*scaleThumbs;
var finalRandomScaledHeight:Number=thumbHeight*scaleThumbs;
var clipsFitX=Math.floor(stage_w/finalRandomScaledWidth);
trace("in loadimages3 function finalRandomScaledWidth is = " + finalRandomScaledWidth);
var clipsFitY=Math.floor(stage_h/finalRandomScaledHeight);
trace("in loadimages3 function finalRandomScaledHeight is = " + finalRandomScaledHeight);
var clipsFitXTotal:Number = clipsFitX+1; // add extra one on the horizontal
var clipsFitYTotal:Number = clipsFitY+2; // add extra two on the vertical
trace ("ClipsFitXtotal) = " +clipsFitXTotal, "(clipsFitYTotal) = " + clipsFitYTotal);
loadnewRow(clipsFitXTotal, clipsFitYTotal,randomScale,finalRandomScaledHeight, finalRandomScaledWidth );
}
function loadnewRow(clipsFitXTotal:Number, clipsFitYTotal:Number, randomScale:Number,
finalRandomScaledHeight:Number, finalRandomScaledWidth:Number):void {
trace("loadnewRow fired ---------------------------------------------------------");
trace("randomScale out of loop but in loadnewRow function loop =" + randomScale);
for (var z:Number =0; z < clipsFitYTotal; z++) {
for (var b:Number = 0; b < clipsFitXTotal; b++) {
var ldr:Loader = new Loader();
var randomSelection = Math.floor( (Math.random()*filePaths.length) );
ldr.load(new URLRequest (filePaths[randomSelection]));
ldr.contentLoaderInfo.addEventListener(Event.INIT, initHandler);
ldr.scaleX=ldr.scaleY=randomScale;//trace("randomScale in the loop is =" + randomScale);
ldr.y=finalRandomScaledHeight*z;//trace("finalRandomScaledHeight*z =" + ldr.y);
ldr.x=finalRandomScaledWidth*b;//trace("finalRandomScaledWidth*b =" + ldr.x);
ldr.alpha=.8;
//trace("[ldr] = number of children = " + ldr.numChildren);
//trace("[THIS] = number of children = " + this.numChildren);
//trace("[THIS] name is = " +this.name);
ldr.cacheAsBitmap = true;
//thumbholder.addChild(ldr);
addChildAt(ldr,1);
filePaths.splice(randomSelection, 1);
if (filePaths.length==0) {
filePaths.push("thmb1.swf","thmb2.swf","thmb3.swf","thmb4.swf","thmb5.swf",
"thmb6.swf","thmb7.swf","thmb8.swf", "thmb9.swf",
"thmb10.swf", "thmb11.swf");
}
}
}
}