Preloading to a target MC

I’ve been trying to figure this out for awhile now and can’t seem to get it. I can create preloaders that load the main movie with this AS.:

total = _root.getBytesTotal();
loaded = _root.getBytesLoaded();
percentage = Math.floor((loaded/total)*100);
percframe = Math.floor(percentage/2);


if (percentage >= 100) {
} else {
with( {
_xscale = percentage;

Now what I want to do is preload another .swf into an empty holder MC. This is the part I can’t seem to acomplish.

Do I need to put the preloader AS into the holder clip or into the .swf that’s being loaded? Should I use scenes? I’m really at a loss here. Any help would be greatly appreciated.

This is a very common question. Load the movie into an mc called holder, for example, and use


_root.holder - then the actions.

Where does this script go frame, on the holder clip, or in the first frames of the .swf being loaded?

And by the way that’s the quickest and best response I’ve got from a forum. Thanx!

So if I place it on “holder” it will getBytesLoaded(); for all .swf’s targeted to holder?

Now to show the progress it’s the same as my preloader?

The code will go into the swf, that is loaded into holder.

In the swf in the first scene or frames where the preloader is, use


And you’ll have to do this for each swf that you load, because as they load into holder, they’ll work out their own bytesLoaded, etc. by using _root.holder (ie the clip they lie in).

O.K. I’ve run into a little snag:


on (release) {
loadMovie(“cd.swf”, “_root.holder”);

The .swf that is being targeted an preloaded AS in a spereate scene:

is frame:
total = _root.getBytesTotal();
loaded = _root.getBytesLoaded();
percentage = Math.floor((loaded/total)*100);
percframe = Math.floor(percentage/2);


When I test the movie it displays 220 and then stops. The .swf never fully loads or displays. Where did I go wrong?

Can you edit your post and click on disable smilies - there are some probs at the moments that cause code to turn into a smilie.

I’m looking at the rest of the code.

If you’re loading into holder you need to use

total = _root.holder.getBytesTotal();
loaded = _root.holder.getBytesLoaded();



That’s what I have now. It works fine when I test the movie being loaded, it displays the progress and loads. It just dosen’t seem to work when I try to load it into the ain movie.

It displays 220 loaded and stops.

Nevermind (for know) I see my mistake.

Something still not quite right. Now when I test it it just loads the .swf without showing the preolader. It skips over it, seems like. I even cleared my cookies.

Everytime you test your preloader - you will have to clear your browser cache.

Everytime you test your preloader - you will have to clear your browser cache.

Why don’t you use Web Speed Simulator (the name of the app says that all) from ?
You can test preloading, on various simulated modem speed.
You can use it on file mode and… localhost mode (port 81)
ehm… it’s trial I know… Just download it!

I’ve heard about the low speed simulators. Never used them. Heard varying opinions about them.

It’s my everyday tool flex.
Just try it to html pages containis swf…(!)
You’ll see all kind of preloaders to work.

I’ll try it - only one way to find out if it really works, I suppose - have you got the url?