Flash – AS3 : How to load external SWF file into a Parent SWF file in ActionScript 3.0 (AS3)?

flash-logoSWF files are loaded using the Loader class. To load an external SWF file, you can follow the steps below.

     

  1. Create a new URLRequest object with the url of the file.

  2. Create a new Loader object.

  3. Call the Loader object’s load() method, passing the URLRequest instance as a parameter.

  4. Call the addChild() method on a display object container (such as the main timeline of a Flash document) to add the Loader instance to the display list.

Sample code in ActionScript 3.0 :

var request : URLRequest = new URLRequest(“http://www.yoursite.com/file.swf”);
var loader:Loader = new Loader()
loader.load(request);
addChild(loader);

You can load external SWF in movieClip or directly on your flash timeline.