Pre-loading one external clip while another plays

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

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

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’d like to do the exact same thing basically

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

Soo…anyone, anyone?

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;
}
}

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.

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.

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!

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.