Not Another Preloader Question!…

I can’t look at more preloader posts!

Preloading external files is fundamental and it’s not difficult. Why do people complicate things?

There are two approaches:

  1. main.swf loads external.swf
  2. main.swf preloads itself

Approach 1:
main.swf loads external.swf.

This is my preferred approach.

Code goes in main.swf, external.swf doesn’t have to know that it’s being loaded or that main.swf exists
It always works in the same way. No surprises. It’s valid for any file type: .swf, .jpg, .gif or .png.

Approach 2:
main.swf preloads itself.

I don’t like this approach.

Obviously it just works with .swf files. You’ll still have to use the first approach for other file types.
You need to have the original .fla as the .swf is not enough.

Why I don’t like Approach 2:
It leads to questions like:

why can’t I see the loading progress before 30, 40 or 50%?

Because everything you have in your library which has been exported for ActionScript (Movie Clips, images, sounds, Components) is set to be exported in the first frame by default.

Export for ActionScript - Export in first frame

The same happens with external Class Files.

Export frame for classes

This leads to a big load in the first frame, which will probably represent those 30 or 40% of the total weight of your Flash movie.

bandwidth profiler

This has a solution: for items in the library, uncheck the “Export in first frame” box.

Export for ActionScript - Do Not Export in first frame

But there is also a price: you’ll have to manually place these Objects on the stage (usually off stage), before trying to use them via ActionScript, otherwise they won’t be available.
For external Class files, just specify a different frame number, also before trying to use the Class.

Hopefully I’ve just convinced you that Approach 2 is a big hassle and you should go with the Approach 1.

Having Approach 1 in mind there are two possibilities:

  • You’re publishing for Flash Player 7 or later, and you use the MovieClipLoader Class.
  • You’re publishing for Flash Player 6, and you have to write your own code – which is pretty easy.

Only two? Yes. The third possibility is not really a possibility:

  • You’re using Flash 5… and you should choose a new career because Flash 9 or CS3 or whatever will be out in a few weeks, and you’ve been sleeping for toooo looong.

And this is for real. Don’t even consider another possibility besides the MovieClipLoader Class.

Do you think it’s difficult to use? It’s not. Forget about that Flash 5 or MX code that you borrowed from your friend. Forget about loadMovie() or loadMovieNum().

Many people fought for this Class! So use it!

More on this subject:

  1. Introduction to the MovieClipLoader Class
  2. Preloading using the MovieClipLoader Class
  3. Building a Preloader using the MovieClipLoader Class

About nuno mira

flash developer
This entry was posted in 1. Bookmark the permalink.

Comments are closed.