• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

Task: Use Load Movie

In this task you use the Load Movie Action to selectively let the user download just the segments he or she is interested in. Here are the steps to follow:

The name of the game for this task is organization. Remember, haste makes waste. Start with a new empty folder into which you'll save and export all your movies.

Create a new file and set the movie's width and height both to 300. Use Modify, Document (or Ctrl+J) to do this and make sure that Ruler Units is set to Pixels.

Create a simple tween of your choice, but make the tweening object entirely red. Save the movie as red.fla in your folder created in step 1. Do a Test Movie, which will export a movie called red.swf in the same folder as your red.fla file.

Do a Save As, name the file green.fla, and change the color of the tweening object to green. (You may need to change the color in each keyframe.) Remember to save and then Test Movie to create the .swf.

Repeat step 4 but create a file with everything blue.

You should have three .flas and three .swfs (red, green, and blue for both). Close all the Flash files. Then create a new Flash file and save it as main.fla in the same folder. Set this movie's size to 500×500.

This “main” file will load movies into a clip. Draw a square exactly 300×300 (draw any rectangle and then use the Info panel to change its dimensions to 300×300). Make sure there's a line around the box and then delete the fill. Select the entire box and convert to it a symbol (make it a Movie Clip and name it “box”). Name the instance on the Stage “theClip” in the Properties panel while the box is selected.

Now draw a rectangle in the main scene (to become a button). Convert it to a symbol (button) and then access the Actions panel for this button instance. Insert a loadMovie Action (from the Actions section of the Toolbox list). Notice that, by default, your script will read loadMovieNum. Simply change the location drop-down (in the parameters area of the Actions panel) to Target (which really should be thought of as “clip”). For the URL parameter, just type red.swf, and then in the field to the right of Target, type theClip, because this is the name of the clip into which you want to load the movie (see Figure 19.1).

Figure 19.1. Load Movie requires that you specify what movie (URL) you want to load and whether you want to load it into a target (a clip) or a level number. Here, a clip instance name already on the Stage is specified.

Test the movie. It should work, except the movie loads into its box too far down and to the right. Although the movie that gets loaded is the same size as the box, it gets positioned with its top-left corner registered to the center of the clip into which it is loading.

The way to fix this is to go inside the master version of the “box” clip and move the contents (the box you drew) so that the top-left corner lines up with the “center” plus sign inside the Movie Clip (see Figure 19.2). You can use the Info panel while inside the Movie Clip to set the top-left corner of the selected shape to position 0,0. When you return to the scene, your clip appears to have moved, but really you've just repositioned where the contents load. Move the box to a location toward the center of the screen (basically, wherever you want it).

Figure 19.2. Editing the relative center point of the master version of the clip in which you're loading movies will affect the positioning of the loaded movie. That is, the loaded movie's top-left corner corresponds to the clip's center point.

You can now make two more buttons and use the same basic Load Movie Action, except change the URL to point to green.swf and blue.swf.



Not a subscriber?

Start A Free Trial

  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint