Preload code isn't working! Why?

I am using thise code to load 15 images but its not working. Maybe someone can spot whats wrong. Here is the code in action: http://s91931107.onlinehome.us/preloader/
The orange light turns on too fast to have preloaded all 15 images and when i go directly to the path of the image it still has to load (so the preload didnt work). The fifteenth image is the only one that appears instantly when i link directly to it…
http://s91931107.onlinehome.us/preloader/weddingsintro4.jpg
http://s91931107.onlinehome.us/preloader/weddingsintro15.jpg
I put on a trace on the getbytestotal for emptyMC and it said 0, so that may be the problem

Anyway, here ya go:

this.onLoad = function() {
for (i=1; i<16; i++) {
allimages.createEmptyMovieClip(“holder”+i, 1+i);
emptyMC = “holder”+i;
section = “weddingsintro”;
image = section+i+".jpg";
allimages.loadMovie(image, emptyMC);
allimages._alpha = 0;
trace (i + “loaded”);

allimages[emptyMC].onEnterFrame = function() {
if (this.getBytesLoaded() == this.getBytesTotal()) {
this.loaded = true;
}
}

}
}

this.onEnterFrame = function() {
var completed = 0;
for (i=0; i<16; i++) {
if (allimages[“holder” + i].loaded == true) {
completed++;
trace (i + “completed”);
}
}
if (completed == 15) {
DONE.play();
}
}

This question has been answered already. Please refer to one of the 534,187,843,214 corresponding posts :slight_smile:

LOL true,

Umm gragland this bit doesnt make sense


allimages.createEmptyMovieClip("holder"+i, 1+i);
emptyMC = "holder"+i;
section = "weddingsintro";
image = section+i+".jpg";
allimages.loadMovie(image, emptyMC);

Shouldnt it read…


allimages.createEmptyMovieClip("holder"+i, 1+i);
emptyMC = "holder"+i;
section = "weddingsintro";
image = "section"+i+".jpg";
allimages.loadMovie(image,"holder"+i);

Anyway just a thought…TIP: use the AS tags to post your code for readability :wink:

But emptyMC = “holder”+i, so it shouldn’t matter if i put emptyMC there.
And I have done a lot of searching and have yet to find code that preloads dynamically loaded images into dynamically created MC’s.

Ahh yeah sorry i didnt see the bit where you stored the var name in emptyMc soz. Hmm there are some components that do this, im in the process of doing something similar myself for a gallery…any gtg. If i have time ill have a look, but hopefully in the meantime someother kind soul from kirupa can help u

nevermind, i managed to make a preloader that does what i need. thanks