Loading External MovieClips in Flash

Loading external MovieClips is one of the easiest ways to keep your SWF file size down and and load times low…

Regular Feature: How-To's Day

Loading external MovieClips is one of the easiest ways to keep your SWF file size down and and load times low. For example, if one were creating a portfolio in Flash, one could make a main movie, and then another movie for each piece of work to be loaded. Then when a user browses the portfolio, they need only wait for the pieces they’ve selected, rather than wait for all pieces to load. One can also apply the loadMovie action to non-progressive JPGs.

There are a few ways to approach loading external SWFs. First is loadMovie, second is MovieClip.loadMovie, and last is loadMovieNum. Luckily, they’re fairly similar, and only require two paramaters, a URL and target or level. loadMovie and MovieClip.loadMovie are both used to load an SWF into the current timeline, or an instance of a MovieClip. In use it would look something like this:

loadMovie("myfilename.swf", mytarget);

or
myMovieClipInstanceName.loadMovie("myfilename.swf")

If you do not specify a target, the SWF will load in the next available level. Your SWF or JPG will inherit the position, rotation, and scale of a targeted movie clip. If your target is the _root timeline, the item will align its upper left corner to the upper left corner of the stage. If you want to load multiple external SWFs, loadMovieNum is the better route. With loadMovieNum, you specify a level for your target, for example:

loadMovieNum("myfilename.swf", 1);

both methods allow you to additionally send variables using the string GET or POST:

loadMovieNum("myfilename.swf", 1 [, yourvariable] );

Using loadMovieNum will enable you to refer to your external movies by level later on (using the syntax _level1, the number being your appropriate level number), without relying on a MovieClip container. This is useful when you want to use unloadMovieNum later on to optimize your movie for better performance.

How-To’s Day is a regular Designorati feature in which we give you fresh tutorials across all of Designorati. How-To’s Day happens every other Tuesday.

Print This Page
Subscribe to the Discussion Surrounding This Article
EMail This Page to a Friend
  1. i get the problems regarding the external file movie.swf

    the problems are:
    main menu with the
    button1 menu (this button to link external .swf file)
    but i want this external file play with the different windows

    this my main menu

    button1 external2.swf
    button2 external3.swf

    help please

    08 May 2006

*Enter Your Name (Required)
*Enter Your Email Address (Required and Kept Confidential)
Enter Your Web Address (Optional)
An asterisk (*) in the field name indicates required information.
We reserve the right to edit or delete comments for any reason.