# Preload code isn't working! Why?

**URL:** https://forum.kirupa.com/t/preload-code-isnt-working-why/52830
**Category:** flash
**Created:** [May 27, 2004, 8:40pm UTC](https://forum.kirupa.com/t/preload-code-isnt-working-why/52830 "2004-05-27T20:40:51Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![gragland](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/gragland/32/422_2.png) [@gragland](https://forum.kirupa.com/u/gragland)
#### Post date: [May 27, 2004, 8:40pm UTC](https://forum.kirupa.com/t/preload-code-isnt-working-why/52830/1 "2004-05-27T20:40:51Z")

</div>

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/](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/weddingsintro4.jpg)  
[http://s91931107.onlinehome.us/preloader/weddingsintro15.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();  
}  
}
