Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

londonweb

macrumors 6502
Original poster
Sep 14, 2005
260
0
london
I'm having some trouble with the following code- the idea is that it keeps loading jpegs until it runs out of them, ie. a load error occurs. The loading sequence works fine if I manually set a limit on the loop (say 28 for 28 jpegs) but this is part of a website for a photographers' agency website, and each photographer will have a different number of pictures, so I want it to be as dynamic as possible.

So I'm trying to break the loop with a function that is triggered by a load error. The trigger itself works- I put a trace in to test it- the problem seems to be that I can't break the loop from within the function. If I try to set a variable in the function, it returns undefined if I refer to it from outside the function in the for loop...

Any help greatly appreciated!

here is the offending code:

Code:
function loadImages(artist, book, final) {
	
	for (var j=1; j<final; j++) {
	
	thumbNail.duplicateMovieClip("thumbNail_"+j, j);
	tMCL.loadClip("../images/"+artist+"/thumbs/"+artist+"_"+book+"_"+j+".jpg", ["thumbNail_"+j].thumbHolder);	//duplicates movie clip and loads thumbnail into it
	
	tListener.onLoadError = function() {
	trace("bollockit");
	} // end function

	} // end for
	
} //end function
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.