Version: Macromedia Flash 5
Objectives: Using Load Movie to load external movies as part of a Flash website.
Tools & Techniques: Load Movie, loadMovie, levels, buttons
Using Load Movie
This lesson will demonstrate how to load external Flash movies. A major reason to load external movies is file size. By loading only the movies you or your visitors want to view, you can keep your initial movie size considerably lower. For example, in this tutorial we created a sample Flash website with separate, external movies for the About, Product, and Contact sections.
If a viewer only wanted to view the info on Products, he/she can click the Products button and that info will load without having to wait for the other areas to load as well. This technique is great for larger, more content-rich movies.
We’ll assume you know how to create a basic Flash movie for this lesson.
Step 1: Getting Started
I created 5 movies for this example: 1 main movie and 4 additional content movies.
- Create one main movie to serve as the “container” or background movie
- This movie will always remain at Level 0 and we’ll load the other 4 movies on top of it at Level 1
Step 2: Open the movie you want to use as the background or main movie
This will be the movie that you use to load the other movies on top of. In my example, it’s “loadmovie.swf”
I don’t have any buttons on this movie, only graphics and some text. Instead of using a button to load the first movie, I’m going to apply a frame action that loads the first external movie when the movie begins.
Step 3: Create the Load Move action at Frame 1
- To load the first movie when the main movie is launched, create a frame action that loads the movie.
- Click in Frame 1 of the background movie and in the Basic Actions Panel, click Load Movie. The loadMovieNum action appears in the first line.
- In the URL field, type in the exact name of the first movie you want to load. In my example, I typed in: main.swf. This is the path to the movie so be sure to type the path correctly. I’m using relative paths here to keep things simple.
- For Level, choose any number greater than 0. Level O is where the background layer is stored so you want to load your other movies on top of it. You can load the other movies into Level 0 but it will replace your current background movie. There are times when that’s more appropriate, but in this example, we’ll just load the other movies in Level 1, above our main, background movie.
!Be sure to include the “.swf” extension. Keep the Expression box unchecked.
The Framerate of the original movie is the framerate all other movies will play, regardless of their individual settings.
Step 4. Save and Publish your movie
Save the movie to a common folder with your other movies.
Step 5. Create loadMovie actions on your other movies
Our main movie, loadmovie.swf had the loadMovie action on the first frame. For the other movies, we’ll create button actions that load the appropriate movie when the viewer clicks on it.
- Open the main.fla movie. We won’t go through the other two .flas since the actions will be the same.
- Click on Frame 25. This is where all of our graphics are in their final position and you can easily access the buttons there.
Step 8. Add the button actions
- Click once on the About button.
- Go to the Actions Panel and under Basic Actions, choose Load Movie.
Step 9. Enter the URL and Level
Type in about.swf in the URL field and for Level, enter 1.
Continue adding the actions for the other buttons (products.swf and contact.swf) in the same manner
You’ll also need to add the same button actions for the other three movies (about.fla, product.fla, and contact.swf).
Step 10. Save and Publish
- Save and Publish all the movies into the same folder
- Test your movies by double-clicking loadmovie.swf
Couple of notes on Loading movies:
1. When you load a movie, the movie that is loaded in the higher level retains it’s transparency. You can use this to your advantage by loading movies on top of your lower movies without having to replace the content underneath.
2. To do this, simply load the movie on a higher level. For example, you might have your initial background movie at Level 0 and another movie on Level 1. You can then load any other movies on any number above 1.
3. Loaded movies are loaded and positioned by their top-left corners. This means that if you load a movie that is smaller in stage size than the original movie, its top left corner will match the original and if you didn’t plan out the positioning ahead of time, it could be off center.