back to home
back to home
back to home  
TECHNOLOGY SUPPORT: HOW TO LOAD EXTERNAL VIDEO INTO FLASH    
 
 
    Using the loadMovie() Function
 

The loadMovie() function is used to replace a movie clip object in Flash with a SWF video file. The SWF file will inherit the position, rotation, and scale properties of the targeted movie clip it replaces. The upper left corner of the loaded image or SWF file aligns with the registration point of the targeted movie clip.

Three parameters can be passed to the loadMovie() function:

loadMovie(url, target, method);

  • url: String - This should contain the URL (absolute or relative) to the SWF file to be loaded into the movie clip object. If WDIG will be passing the URL as a variable, please use _level0.moviePath
  • target: Object - This is a reference to a movie clip object to be replaced by the SWF video file.
  • method: String (optional) - This specifies an HTTP method for sending variables (either the string GET or POST). Omit this parameter if there are no variables to be sent.

Example of the loadMovie() function with a hard-coded SWF url:

loadMovie("http://www.server.com/video.swf", "movie_placeholder");

Example of the loadMovie() function with a variable url value (to be set by WDIG):

loadMovie(_level0.moviePath, "movie_placeholder");

    A Working Example of the loadMovie() Function
 

The following example expects a variable, _level0.moviePath, to be set externally when the SWF file is published to the page.

When the user clicks the play button the ad will replace the movie_placeholder object with the SWF file defined by the _level0.moviePath, in this case test_movie.swf.

Click on the play button to view the example. The code is briefly explained below. Click here for a zip file containing the original files for reference.

The actionscript code associated to the play button in the main SWF file:

   on (release) {
	loadMovie(_level0.moviePath, "movie_placeholder");
}

Initializing the _level0.moviePath variable upon page render:

   SOB.flashFile = "sample_300x250.swf?moviePath=test_movie.swf";

    References
 

Adobe LiveDocs - The official documentation on the Adobe Flash loadMovie() function.

Zip File (10k) - A file containing the original Adobe Flash FLA file used for the example above.