# Multiple Preloader with x movies loaded to targets

**URL:** <https://forum.kirupa.com/t/multiple-preloader-with-x-movies-loaded-to-targets/1018>\
**Category:** Uncategorized\
**Created:** [August 6, 2002, 5:34pm UTC](https://forum.kirupa.com/t/multiple-preloader-with-x-movies-loaded-to-targets/1018 "2002-08-06T17:34:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bellir](https://avatars.discourse-cdn.com/v4/letter/b/e274bd/32.png) [@bellir](https://forum.kirupa.com/u/bellir)\
**Post date:** [August 6, 2002, 5:34pm UTC](https://forum.kirupa.com/t/multiple-preloader-with-x-movies-loaded-to-targets/1018/1 "2002-08-06T17:34:14Z")

</div>

I kinda of like the code below, I used on my project, but the button play/enter won’t work. No matter what code I use.

Multiple Preloader with x movies loaded to targets

Simply put all your movies to load and the corresponding  
targets in the array moviearray. Remember: If you don’t  
want the loaded clips to start immediatly after beeing  
loaded, you have to place a stop action in the first  
frame of the movie.

frame 1:  
//provide a list with all your movies to load and the targets to load into  
moviearray = new Array(“movie1.swf”,“target1”,“movie2.swf”,“target2”,“movie3.swf”,“target3”);  
//set the index of the first movie to load  
actMovieIdx = 0;

frame 2:  
// get the next moviename and level  
moviename = moviearray[actMovieIdx++];  
movietarget = moviearray[actMovieIdx++];  
// load the given movie  
loadMovie(moviename, movietarget);

frame 3:  
// nothing in here

frame 4:  
//get the actual loaded bytes  
actBytes = eval(movietarget).getBytesLoaded() || 0;  
// get the total bytes to load  
totBytes = eval(movietarget).getBytesTotal() || 100;  
// calculate the percentage loaded  
percent = Math.round(actBytes \* 100 / totBytes);

if( totBytes - actBytes \> 10){//more bytes available, keep on loading  
gotoAndPlay(3);  
} else if(actMovieIdx \< moviearray.length){//if we got more movies to load  
gotoAndPlay(2);  
} // else go to frame 5

frame 5:  
// ready, go - here starts your movie

tks  
bellir

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 6, 2002, 11:47pm UTC](https://forum.kirupa.com/t/multiple-preloader-with-x-movies-loaded-to-targets/1018/2 "2002-08-06T23:47:40Z")

</div>

// frame 1:  
moviearray = [“mySwf0.swf”, “mySwf1.swf”, “mySwf2.swf”, “mySwf3.swf”, “mySwf4.swf”];  
for (ii=0; ii\<moviearray.length; ii++) {  
\_root.createEmptyMovieClip(“movie”+ii, ii);  
\_root[“movie”+ii].loadMovie(moviearray[ii]);  
}  
// frame 2:  
nTotalBytes = 0;  
for (ii=0; ii\<moviearray.length; ii++) {  
nTotalBytes += \_root[“movie”+ii].getBytesTotal();  
}  
// frame 3:  
// nothing  
// frame 4:  
nLoadedBytes = 0;  
for (ii=0; ii\<moviearray.length; ii++) {  
nLoadedBytes += \_root[“movie”+ii].getBytesLoaded();  
}  
nPercentLoaded = nLoadedBytes/nTotalBytes\*100;  
if (nPercentLoaded\<100) {  
this.gotoAndPlay(this.\_currentframe-1);  
} else {  
play();  
}

that should work.  
🙂  
jeremy

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 7, 2002, 5:45am UTC](https://forum.kirupa.com/t/multiple-preloader-with-x-movies-loaded-to-targets/1018/3 "2002-08-07T05:45:39Z")

</div>

Hey Jeremy, I think that a part of your for loops have been deleted by the board.

pom :asian:
