Loading dynamic thumbs/pics (attn: Scotty)

How would I get the first “pic” to show automatically? Since when the code runs, it only shows the thumbs first, until you click on one and then it loads the corresponding pic.

/*The below works if the pictures and thumbs are in a folder "pics"
the thumbs are named "thumb1.jpg" etc and the pictures "pic1.jpg" etc
if you use other names, change it in the code as well;-))

var k = 0;
//nr is amount of thumbs
var nr = 2;
//gap is the gap between the thumbs
var gap = 10;
//c is the amount of columns
var c = 3;
//set the original thumb invisible
thumb._visible = 0;
//function to create the thumbs
function createThumbs() {
	for (var i = 0; i<nr; i++) {
		//duplicate the original thumb
		duplicateMovieClip("thumb", "pic"+i, i);
		//give the copy a (more easy) name
		p = this["pic"+i];
		//give the copy it's own identifier
		p.i = i;
		//set the x position of each thumb
		p._x = 300+((i%c)*(p._width+gap));
		//set the y position of each thumb
		p._y = 350+((Math.floor(i/c))*(p._height+gap));
		//set the actions for the thumb you can add rollover etc
		p.onRelease = function() {
			//load the pic in container , here you need the identifier;-))
	//call the loadthumb function
function loadThumb(k) {
	//give the "container" inside the thumb a name
	mc = this["pic"+k].th_pic;
	//load the thumb
	//set the thumb picture invisible
	mc._visible = 0;
	//create an emptymovieclip
	ab = this.createEmptyMovieClip("temp", 100);
	ab.onEnterFrame = function() {
		//if the thumb picture is fully loaded
		if (mc.getBytesLoaded() == mc.getBytesTotal() && mc.getBytesTotal() != 0) {
			//set the thumb picture visible
			mc._visible = 1;
			delete this.onEnterFrame;
			//if not all thumb pictures are loaded
			if (k<nr) {
				//call the nextthumb function
				//I've used a setinterval here cause the thumbs are very small
				//so the effect of consecutive loading is small as well
				//change the 300 to the value you like (300 is in msecs)
				delay = setInterval(nextThumb, 300);
function nextThumb() {
	//increase the value k
	//call the function loadthumb
	//clear the interval
//call function createthumbs (to start it all;-))

Also, what would I have to change in order to load swf’s as opposed to just the “pics”? I know it would involve changing this line of code…



For the swf’s:


if they’re in a folder pics;)

For loading the first pic:
grr can’t copy the part I need, moment:lol:


Back again=)
Look for the if(k<nr){ part in the code and add the else statement

	if (k<nr) {
	delay = setInterval(nextThumb, 300);
} else {

Not tested, but a good chance it’ll work:)


Thanks Scotty, Im gonna try this as soon as I’m done at work.

Brilliant! (as always) :beer:
thanks again Scotty!