Macromedia Flash MX 2004 Tutorial – Part 2

Dividing Files into Multiple SWFs

Movie clips can be exported from the library of a Flash document to create self-contained SWF files. These files can then be played in the Flash Player or loaded into other movies using ActionScript. Exporting movie clips is yet another way Flash promotes reusability.

To export a movie clip:

  1. In the library, locate the movie clip you want to export.
  2. Right-click on the movie clip and select Export Flash Movie from the shortcut menu.

  1. In the Export File dialog, navigate to the folder where you want to save the file and give it an identifiable name:

  1. Click Save.

The SWF file can now be loaded into other Flash movies, something that’s common in complex animations to keep the final file size down (external files remain external to the main movie). To demonstrate this, we’ve exported our weather movie clip and deleted it from the Stage. Now, we’ll load it back into the movie using ActionScript:

  1. In the Main Timeline, create a layer called “Actions”.
  2. Select the first frame of the Actions layer and open the Actions panel.
  3. Locate the loadMovie action in the Browser/Network group and double-click it to add it to the Script pane. You could also type loadMovie(); directly into the Script pane:

  1. The loadMovie() action has three parameters: URL, target, and method. Only the first two are required. URL is the location of the external SWF you’re inserting and target refers to the object into which you want to load the external file. Below, we’ve added the two parameters to the Script pane:

“weather.swf” is the animated weather movie clip we exported and now want to load into our movie. Because it resides in the same folder as our main Flash file, we don’t need to specify a path to it. “this” refers to the current location—in this case, the Main Timeline. You could also specify a target movie clip here.

Tip:

Use the Insert a target path button to insert a target using the correct path from the current location: When you click this button, Flash opens the following dialog, allowing you to select the Main Timeline (“this” or “_root”) or a named movie clip instance:

  1. That’s it! When our movie plays, the animated weather movie clip appears:

Macromedia Flash MX 2004 Part 2: Section 1

In this section, you learned about:

  • Creating buttons
  • Adding behaviors to buttons
  • Creating movie clips
  • Dividing files into multiple SWFs

Leave a Reply

Your email address will not be published. Required fields are marked *