# Preloader

**URL:** https://forum.kirupa.com/t/preloader/31119
**Category:** Uncategorized
**Created:** [September 18, 2003, 1:36pm UTC](https://forum.kirupa.com/t/preloader/31119 "2003-09-18T13:36:48Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![xcrap](https://avatars.discourse-cdn.com/v4/letter/x/ba8739/32.png) [@xcrap](https://forum.kirupa.com/u/xcrap)
#### Post date: [September 18, 2003, 1:36pm UTC](https://forum.kirupa.com/t/preloader/31119/1 "2003-09-18T13:36:48Z")

</div>

Hi.

I have a movie in a single frame that have the following action script to random load external swf’s.

I wonder how can i do to preload the swf’s first

```auto

function virgem(){
movies = [1,2,3,4,5];
last = Math.floor(Math.random()*movies.length);
loadMovie("random_index_port/random" + movies[last] + ".swf","background");
}

function rnd(){
movies = [1,2,3,4,5];
choice = Math.floor(Math.random()*movies.length);
 while(choice == last) {
 choice = Math.floor(Math.random()*movies.length);
 }
last = choice;
loadMovie("random_index_port/random" + movies[last] + ".swf","background");
}

a=1;
if (a==1) { virgem(); a=2; }

timer = setInterval(rnd,10000);
stop();

```

I’ve seen this code somewhere… a preloader…

```auto

frame 1:
loadMovie("myMovie.swf","myTarget");

frame 2:
// nothing in here

frame 3:
actBytes = myTarget.getBytesLoaded() || 0;
totBytes = myTarget.getBytesTotal() || 100;
percent = Math.round(actBytes * 100 / totBytes);

if( totBytes - actBytes > 10){
	// if you don't want a bar, delete the following line
	bar._xscale = percent;
	gotoAndPlay(2)
}

frame 4:
// ready, go

```

But i’m not using gotoandplay in my movie and he starts playing the swf right away, so won’t the second preloader example do the same… help 🙂
