# Pre-loading one external clip while another plays

**URL:** <https://forum.kirupa.com/t/pre-loading-one-external-clip-while-another-plays/56907>\
**Category:** Uncategorized\
**Created:** [July 8, 2004, 6:36pm UTC](https://forum.kirupa.com/t/pre-loading-one-external-clip-while-another-plays/56907 "2004-07-08T18:36:33Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![seren8](https://avatars.discourse-cdn.com/v4/letter/s/47e85d/32.png) [@seren8](https://forum.kirupa.com/u/seren8)\
**Post date:** [July 8, 2004, 6:36pm UTC](https://forum.kirupa.com/t/pre-loading-one-external-clip-while-another-plays/56907/1 "2004-07-08T18:36:33Z")

</div>

Hello,

Here is what I am trying to do…

I am going to have a single page, with a 6 minute sound clip looping (don’t ask - sort of a for-fun site I am doing at work). I have broken the clip down into 12 smaller clips to reduce file size, and I want to have a random clip play each time a user refreshes, but then have the clips play sequentially from wherever they start (e.g. randomly start with clip 10, then play 11, 12, 1, 2, etc.). I have created 12 different flash files, each with one of the sound clips.

I am using the randomize script found here, which is working fine:

[http://www.kirupa.com/developer/actionscript/loading\_random\_movie.htm](http://www.kirupa.com/developer/actionscript/loading_random_movie.htm)

On the last frame of each of the 12 files, I am loading the next movie. For example, clip 1 has:

```auto
loadMovieNum("clip2.swf", 0);

```

Everything is working, except I want to have the next sequential sound clip loaded while the current clip is playing, so that the sound plays smoothly with no interruptions. Right now there is a slight pause between each clip.

I have looked through a lot of the pre-loader scripts and posts, but I don’t want to have any sort of obvious pre-loader if I can avoid it (no “loading” bar, etc.). I also was not sure whether I should be putting the code on the main file, or on each of the 12 files (which seems more likely).

If anyone could help, or point me to a previous post that might solve this, that would be great!

Also, if there is an easier way you can think of to do this, that would be great as well (the main reason I separated them into separate .swfs is because I thought it would load quicker when the user first gets to the page).

Thanks!

---

<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:** [July 9, 2004, 5:12pm UTC](https://forum.kirupa.com/t/pre-loading-one-external-clip-while-another-plays/56907/2 "2004-07-09T17:12:25Z")

</div>

I’d like to do the exact same thing basically

---

<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:** [July 9, 2004, 7:38pm UTC](https://forum.kirupa.com/t/pre-loading-one-external-clip-while-another-plays/56907/3 "2004-07-09T19:38:06Z")

</div>

Here I am all excited that someone replied, and then…imagine my disappointment. 🙂 lol.

Soo…anyone, anyone?

---

<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:** [July 9, 2004, 8:53pm UTC](https://forum.kirupa.com/t/pre-loading-one-external-clip-while-another-plays/56907/4 "2004-07-09T20:53:45Z")

</div>

Ok, try this. It works for my swf’s, you just need to download the preloader class com.qlod.LoaderClass. I have the code if you need it. Just put the names of your clips in swf\_array. Also, two clips are always running at the same time, so if that’s not ok (i.e. your sounds might be screwy) you may need to add something to the if statement to make the unneeded one stop. This isn’t the best code but it seems to work for me seemlessly.

swf\_array = [“part1.swf”,“part2.swf”,“part1.swf”,“part2.swf”,“part1.swf”,“part2.swf”,“part1.swf”,“part2.swf”,“part1.swf”,“part2.swf”,“part1.swf”,“part2.swf”];  
counter = 0;  
var tc = this.createEmptyMovieClip(“TopClip”,3);  
var bc = this.createEmptyMovieClip(“BottomClip”,2);  
myLoader = new com.qlod.LoaderClass();  
var tcflag = false;  
var bcflag = false;  
this.onEnterFrame = function()  
{  
if(counter == 0)  
{  
myLoader.load(tc,swf\_array[counter]);  
counter++;  
myLoader.load(bc,swf\_array[counter]);  
counter++;  
}  
else if(tcflag)  
{  
tcflag=false;  
tc.swapDepths(2);  
tc.unloadMovie();  
bc.gotoAndPlay(1);  
myLoader.load(tc,swf\_array[counter]);  
counter++

}  
else if(bcflag )  
{  
bcflag=false;  
bc.swapDepths(2);  
bc.unloadMovie();  
tc.gotoAndPlay(1);  
myLoader.load(bc,swf\_array[counter]);  
counter++  
}  
else if(tc.\_visible && tc.\_totalFrames == tc.\_currentFrame)  
{  
tcflag = true;  
}  
else if(bc.\_visible && bc.\_totalFrames == bc.\_currentFrame)  
{  
bcflag = true;  
}  
}

---

<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:** [July 11, 2004, 9:55am UTC](https://forum.kirupa.com/t/pre-loading-one-external-clip-while-another-plays/56907/5 "2004-07-11T09:55:27Z")

</div>

> [@seren8](#):
>
> Hello,
> 
> Here is what I am trying to do…
> 
> I am going to have a single page, with a 6 minute sound clip looping (don’t ask - sort of a for-fun site I am doing at work). I have broken the clip down into 12 smaller clips to reduce file size, and I want to have a random clip play each time a user refreshes, but then have the clips play sequentially from wherever they start (e.g. randomly start with clip 10, then play 11, 12, 1, 2, etc.). I have created 12 different flash files, each with one of the sound clips.
> 
> I am using the randomize script found here, which is working fine:
> 
> [kirupa.com - Loading Random Movies](http://www.kirupa.com/developer/actionscript/loading_random_movie.htm)
> 
> On the last frame of each of the 12 files, I am loading the next movie. For example, clip 1 has:
> 
> ```auto
> loadMovieNum("clip2.swf", 0);
> 
> ```
> 
> Everything is working, except I want to have the next sequential sound clip loaded while the current clip is playing, so that the sound plays smoothly with no interruptions. Right now there is a slight pause between each clip.
> 
> I have looked through a lot of the pre-loader scripts and posts, but I don’t want to have any sort of obvious pre-loader if I can avoid it (no “loading” bar, etc.). I also was not sure whether I should be putting the code on the main file, or on each of the 12 files (which seems more likely).
> 
> If anyone could help, or point me to a previous post that might solve this, that would be great!
> 
> Also, if there is an easier way you can think of to do this, that would be great as well (the main reason I separated them into separate .swfs is because I thought it would load quicker when the user first gets to the page).
> 
> Thanks!

I am assuming that you have broken your sound clip up into seperate files.  
I think you would be better keeping your sound clip altogether and streaming it. Also rather than load each of your movies into level0, It might be better to pick another level. If I have time later, I`ll try make an example for you.

---

<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:** [July 12, 2004, 1:52am UTC](https://forum.kirupa.com/t/pre-loading-one-external-clip-while-another-plays/56907/6 "2004-07-12T01:52:53Z")

</div>

> [@jla2w](#):
>
> Ok, try this. It works for my swf’s, you just need to download the preloader class com.qlod.LoaderClass. I have the code if you need it. Just put the names of your clips in swf\_array. Also, two clips are always running at the same time, so if that’s not ok (i.e. your sounds might be screwy) you may need to add something to the if statement to make the unneeded one stop. This isn’t the best code but it seems to work for me seemlessly.

Thanks…I will definitely give this a try tomorrow at work. I hate to be so clueless about this (I want to know everything about Flash, and I want to know it now!! lol) but how do I download/integrate the class?

A couple of other questions:

- Where would I put the “Stop” for the second clip?
- Does this script still randomize the clips?

Thanks for your help.

---

<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:** [July 12, 2004, 1:53am UTC](https://forum.kirupa.com/t/pre-loading-one-external-clip-while-another-plays/56907/7 "2004-07-12T01:53:53Z")

</div>

> [@stringy](#):
>
> I am assuming that you have broken your sound clip up into seperate files.  
> I think you would be better keeping your sound clip altogether and streaming it. Also rather than load each of your movies into level0, It might be better to pick another level. If I have time later, I`ll try make an example for you.

Yes, I did break up the 12 clip into 12 separate files, and then I created 12 separate swf files. I did that because I thought it would load quicker as small files rather than 1 big file. If streaming is better then I would love to see your example. I’m still new to this so it wasn’t something that had crossed my mind.

If I streamed the big file, could I still have the randomize function? Would it just be by jumping to a random frame label (corresponding to specific points on the clip) with each page refresh or something like that?

Thanks!

---

<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:** [July 12, 2004, 1:12pm UTC](https://forum.kirupa.com/t/pre-loading-one-external-clip-while-another-plays/56907/8 "2004-07-12T13:12:51Z")

</div>

It doesn’t randomize the clips. That is something you should still do in your code. Initialize your counter to loop continuously through, starting at your random value, and moving on through all your clips. You will probably have to change some code, this is just something that I’ve found works.
