Preloading using on clip event?

I am using loadmovie to load a separate .swf file into a movie clip which is on my main file time line.
Is there anyway I can use Onclipevent () to preload the movie I am loading in?

(Iceman offered some code but I couldn’t get it to work)

do you need to preload the movie in the main movie or the loaded one?:-\
on the loaded on is easier…

The problem I have is that on a slow connection 56K or slower, the sub-movies I am loading in can take seconds to appear. There is quite a large pause. Each has a preloader at the start of it.

Iceman said words to the effect of : you can eliminate the pause if the preloader for the sub-movies is on the main movie timeline attached to the movie clip I am loading the files into.

To simplify : I want the preloader for the sub-movies on the main timeline.

I hope that clarifys.

Any ideas?

I’m after one of those too, one…


I am currently 85% done with my new preloader experiment.

It is, in short, a preloader that works in conjunction with a function in the main movie. This in turn is called upon to preload any particular object in the movie.

It’s currently working, but has some bugs to be ironed out.

If I can figure out how to explain what it is that I’m doing, I’ll post that info here tomarrow. Might take me a little longer though. I sort of create as I go along… a bad way to do it for sure… it always takes me a couple of days to sort all of the stuff I created into anything comprehensible.

>> this is frame actions of fr1 in main movie::

// Feb 6th, 2002
// Sequential Preloader BETA 2 by Jesse Stratford
//, [email protected]
// --------------------------
// initialize counter variables
count = 0;
// how many movies are we going to be loading?
numMoviesToLoad = 2;
// define our loadNext function
function loadNext () {
// we’re no longer preloading the last movie
_root[“loadcontainer”+count] = false;
// send the percent bar back to it’s first frame (0%);
// if there are still movies which need loading
if (count<numMoviesToLoad) {
// incriment counter
// instance name for the next container MC
var newName = “container”+count;
// duplicate the container MC
_root.container.duplicateMovieClip(newName, count);
// this is my debugging code
with (this[newName]) {
_x = random(150);
_y = random(150);
_xscale = random(100);
_yscale = random(100);
_alpha = 50;
// end debugging
// load the next movie in the sequence into the new container
loadMovie (“phase”+count+".swf", _root[newName]);
// we are now preloading a new movie, set the var to True
_root[“load”+newName] = true;

>> then, this is the obk=ject actions on a blank mC called container::
onClipEvent (enterFrame) {
// if this movie needs preloading
if (_root[“load”+this._name]) {
// has the loadMovie command been processed yet?
if (total_bytes == null) {
total_bytes = this.getBytesTotal();
} else {
// controll bar - standard % preloader code
loaded_bytes = this.getBytesLoaded();
remaining_bytes = total_bytes-loaded_bytes;
percent_done = int((loaded_bytes/total_bytes)*100);;
// if loading is complete
if (percent_done == 100) {
trace (“fully loaded”);
// not loading this one any more, load the next
_root[“load”+this._name] = false;

::: It all works really wellexcept I can’t get the actual preload displays happening (percent_done, etc.)…

…Edge of my seat…

Interesting. Thanks for the code, I’ll have to break that down to see what’s going on exactly.

Mine is far less extensive in it’s coding, that’s for sure. I do however do an “estimated time remaining for download”, which is nice.

It should look like this: The source files are also here…

Basically, you set the number of movies to load, make sure there are some phase1.swf’s, etc., then the function loadNext loads them all into blank mC’s, whilst also doing the % preloading thing.

Works REALLY well, but on my machine (using MX) the % preloading stuff doesn’t seem to work; nor can I seem to get it to work. Dang.

Sorry I downloaded your .fla and I found the problem I didn’t relize that you were using flash 5 so I just changed a few lines. I have an .fla for your that solved your problem, if you give me your e-mail I can send it to you.

onClipEvent (enterFrame) {
if (total_bytes == undefined) {
total_bytes = this.getBytesTotal();
loaded_bytes = this.getBytesLoaded();
remaining_bytes = total_bytes-loaded_bytes;
percent_done = int((loaded_bytes/total_bytes)*100);
_root.outputfield = percent_done;
Try using this. Hope this helps. Sorry if it didn’t work before.


ok thanks for downloading the .fla, my email is [email protected] :bandit:

I must admit that’s pretty sweet.

I definitely have to break that down before I fully release my final master preloader clip. In my version you have to call out to whatever is being preloaded, but I think I’d like to have each in a que so that it just continues to load each as it can.

Good coding.



thanks for your email and the code Kyle, unfortunately it didn’t preload my movie, it just went ahead and played - even when not fully loaded. Also it showed the numbers ontop of my movie my movie.

I alterred the code alittle to try and sort that problem out :

onClipEvent (enterFrame) {
    if (this.getBytesTotal() == undefined) {
        total_bytes = this.getBytesTotal();
    } else {
        loaded_bytes = this.getBytesLoaded();
        percent = int(this.getBytesLoaded()/this.getBytesTotal()*100); = percent;
        _root.outputfield = int(this.getBytesLoaded()/this.getBytesTotal()*100);
onClipEvent (enterFrame) {
    if (_root.outputfield == 100) {
        _root.outputfield = " ";

Then at the start of the movie I was loading in:

if (_root.outputfield== " "){
gotoAndPlay 3;

in frame 2 I had a command gotoAndPlay 1.

although slightly messy, this coding did work.

However, a new problem arises :slight_smile:

If my movie is loading in, and it gets to eg. 20 and you press another button (or the same button) it shows the number it got to, in this case 20 for a couple of seconds, then jumps back to counting from 0 again. It looks Bizzarre!

so is there anyway I can set _root.outputfield to show nothing (blank) each time I click a button? (I’ve tried a couple of ways neither worked).

also, less importantly, my coding there is a bit messy there - Is there anyway to just alter the code attached to the instance of the clip I am loading into to a) make the number dissapear, and b)stop the movie playing until all 100% is loaded in? I tried and If statement it just seemed to ignore it though :-\

also a question about the command. The x_scale make me think this is a loading bar that increases in horizontal size as it loads in. If I had a graphic symbol on the timeline called .bar would it increase in size, if not how would I make the loading bar work?

the example is the “able grafix” button of

e-mail me your .fla, [email protected]


I suggest that anyone interested in this subject visit Moock’s link, here.

Though I love my work on the preloader… moock is the master. Read his words.

Thanks to all that posted I got it working how I wanted in the end :slight_smile:

Special thanks to Kyle (Iceman) - thanks for all your help.

Hey RageWolf,

Your welcome and the site looks good, I’m glad I could help, if you need help again or anything just e-mail me. By the way I forgot to metion that I really like the design of your site, I like the transitions after the buttons are clicked they’re very “innovative”.

Good luck with the site