How can I to pre-load or load many .swf files

Hello everyone,

I have a bunch of .swf files that I load to empty movie clips.
Anyway in my main .swf file lets call it Main.swf I have 2 scenes:

Scene 1

The preloader scene is the preloader which works well but it only loads that .swf file (Main.swf). What I need is to load all the .swf so then the users can see the page well.

Does anyone knows how to do this??


youd be better off just loading them dynamically, make sure you keep the preloader on the external files, it will work seemlessly without getting into heavy scripting to start redirecting your files

Yes but I dont want to put the preloader on the external files. I want one preloader that loads everything so the user doesn’t need to wait later on. Is this posible?? and if it is how can I achive this??


Create a new movie (.fla) and put the following code on the first frame of the root timeline:

_root.traceBox.vScrollPolicy =“on”;
function myTrace(msg)
_root.traceBox.text += msg + newline;
_root.traceBox.vPosition = _root.traceBox.maxVPosition;

All we’re doing here is setting up a basic trace function, the output of which will be displayed in the TextArea component that we are about to place on the stage. _root.traceBox.vPosition = _root.traceBox.maxVPosition keeps the scrollbar moving as more content is added, so that we can see new traces as they appear without the need to manually scroll. vScrollPolicy makes sure the vertical scrollbar is on at all times.

  1. Now drag an instance of the TextArea component on stage from your components panel, resize it to make it big enough to display our traces properly and give it an instance name of “traceBox”.

  2. The next step is to create a new movieclip symbol, and place 3 instances of that symbol on the main stage, giving them the instance names of “myMC1”, “myMC2” and “myMC3”. We will load our images and swfs in to these, so space them about at 200 pixels apart. Our loaded images will actually be much bigger than 200 pixels wide, but we’ll resize them once they’ve downloaded. It is not good practice to make your images larger than the final size at which they will be displayed of course, but for the sake of this tutorial it will allow us to see the onLoadInit() method in action.

  3. The next thing to do is to create our new MovieClipLoader object which we’ll call myMCL, so add the following code to the first frame, below our trace function:

var myMCL = new MovieClipLoader();//create an instance of MovieClipLoader

  1. Okay with that done we’re now going to assign our first bit of functionality to our MCL object. If you remember, the onLoadStart method of our class is invoked when loading begins. onLoadStart() receives, as an argument, the name of the movieclip instance calling it. Add the following code to frame 1:
    myMCL.onLoadStart = function (targetMC)
    var loadProgress = myMCL.getProgress(targetMC);
    myTrace (“The movieclip " + targetMC + " has started loading”);
    myTrace(“Bytes loaded at start=” + loadProgress.bytesLoaded);
    myTrace(“Total bytes loaded at start=” + loadProgress.bytesTotal);

The first line of code inside our function declares a new variable “loadProgress”, to which we assign the results of our getProgress method (getProgress returns an object with two integer properties: bytesLoaded and bytesTotal). The last two traces send these values (bytesLoaded and bytesTotal) to be displayed in our TextArea component.
6. We have already assigned functionality to our onLoadStart() method. Now we will work through the remaining methods that I listed earlier, and see how we assign functionality to those too. Next up is onLoadProgress() which accepts three arguments (the movieclip in question and its byte-loaded details). Again, we send those details to be displayed in our trace function. Add the following code to frame 1:

myMCL.onLoadProgress = function (targetMC, loadedBytes, totalBytes) {
myTrace ("movie clip: " + targetMC);
myTrace(“Bytes loaded at progress callback=” + loadedBytes);
myTrace(“Bytes total at progress callback=” + totalBytes);

  1. Our onLoadComplete method accepts one argument which is the name of the clip. Again, we assign the results of getProgress to a variable and extract the byte details for display.
    myMCL.onLoadComplete = function (targetMC)
    var loadProgress = myMCL.getProgress(targetMC);
    myTrace (targetMC + " has finished loading.");
    myTrace(“Bytes loaded at end=” + loadProgress.bytesLoaded);
    myTrace(“Bytes total at end=” + loadProgress.bytesTotal);

  2. The onLoadInit function is not executed until the content has fully loaded in to the movieclip. This makes it the perfect place to put any code which will affect your movieclip’s properties. I chose pictures which were quite large for testing purposes, so that we can track the loading progress in the trace box, but we are now going to resize each movieclip so that all the content fits on screen.
    myMCL.onLoadInit = function (targetMC)
    myTrace (“Movie clip:” + targetMC + " is now initialized");
    targetMC._width = 170;
    targetMC._height = 170;

  3. One of the callbacks we have access to is onLoadError. If an error occurs it returns one of three error messages as a string: “URLNotFound”, “LoadNeverCompleted” or “Call Yourself a Programmer?” Okay, make that two.
    myMCL.onLoadError = function (targetMC, errorCode)
    myTrace (“ERRORCODE:” + errorCode);
    myTrace (targetMC + “Failed to load its content”);

  4. Well that’s the hard work out of the way. Now we just have to load the files in to their respective targets, using loadClip, and passing it two arguments: the location of your file, and the destination movieclip for the file to load in to.
    //load the files in to their respective targets
    myMCL.loadClip(" ", “_root.myMC2”);
    myMCL.loadClip(“”, “_level0.myMC3”);

Right, change those paths to make them correct for you, publish the file and upload everything to the same directory on your server. I’ve used absolute paths here but of course relative paths are better used where possible, and if our pictures/swfs are in the same folder as the main swf we would be more likely to type something like:
//load the files in to their respective targets

Now check the results of your hard work in your browser…

Thanks for the information, I will give this a try and let you know

how come when i test the fla the text area component (displaying the trace)doesn’t show up until everything is loaded

Thanks for your help so far fullview