A ton of Flash users visit Adobe’s we site every month wondering about how to load an external SWF file from within another SWF. There are a lot of resources with answers to this question, and I recently realized our own TechNote on the subject was kind of old and crusty. A bunch of users who visited it were having some pretty obvious follow-up questions that weren’t answered by the TechNote as it was, such as:
- How do I load more than one SWF?
- How do I load a SWF into a specific location in the display list?
- How do I resize the loaded SWF?
- How do I set its X and Y location?
So I’ve attempted to answer these questions with an updated code sample and a set of sample files you can download from the TechNote.
I also added a bunch of links to quality resources that elaborate on loading content and on the display list:
- Sample files for this TechNote. A set of 3 FLA and 3 corresponding SWF files, including a parent SWF and 2 SWFs that the parent loads.
- Help > AS3 Developer’s Guide > Loading an external SWF file
- Help > AS3 Developer’s Guide > Loading display content dynamically
- Loading multiple external SWFs within a main SWF – CreativeCow.net forums
- Video tutorial: ActionScript 101 – Episode 6: Adding named objects to the Stage. By Doug Winnie. An example of how to add the loaded external asset to the Stage and modify its location or other properties.
- Video tutorial: Preloading in ActionScript 3.0. By Lee Brimelow. A slightly more complicated example, showing how to make the parent SWF display information about the progress of loading the external SWF.
- Tutorial: Loading and unloading SWFs - FlashAndMath.com
Note also that if your app is running on iOS, you can load external assets, but no ActionScript code.
I’d love to know if you find the updated TechNote helpful and if you have suggestions for further improvement. Let me know in a comment here or on the TechNote page.