g Text Version
Beauty & Self
Books & Music
Food & Wine
Health & Fitness
Hobbies & Crafts
Home & Garden
News & Politics
Religion & Spirituality
Travel & Culture
TV & Movies

Bored? Games!
Take a Quiz
Rate My Photo

Natural Living
Folklore and Mythology
Distance Learning

All times in EST

Full Schedule
g Flash and Animation Site

BellaOnline's Flash and Animation Editor


ActionScript to Load External SWF

Let's add the ActionScript that will load the external ecard swf into our FlashR intro swf. We already have an Actions layer at the top of the Timeline. We created this Actions layer when we built the "Click on Stamp" button on Frame 80.

1. Right-click on Frame 136 and Insert a Keyframe. This will tell Flash to read our ActionScript on this frame. Open the Actions panel (Window Actions) and copy/paste the following code.

var ecard:String = LoaderInfo(this.root.loaderInfo).parameters.ecard;

var myrequest:URLRequest = new URLRequest(ecard);
var myloader:Loader = new Loader();

function swfLoad(myevent:Event):void
var myswf:MovieClip =;
myswf.x = 0;
myswf.y = 0;

myloader.contentLoaderInfo.addEventListener(Event.COMPLETE, swfLoad);

  1. The first line of code creates a string variable to hold the name of the external swf. Notice that we have given the name of "ecard" to the parameter. We will be using this again later.

  2. Next, we create a variable (named myrequest) and a variable (named myloader) for the URLRequest.

  3. Then we write the function (swfLoad) that will load our external swf. This function uses the addChild to add the external swf to the display list for our intro swf and sets the X and Y positions to 0.0.

  4. Finally, we use an EventListenser to tell us when the external swf has been completely loaded. When this is so, we call the swfLoad function.

    Remember that we published our intro fla to tell Flash to generate the swf and HTML files for this project? Now, we will add a little code to the HTML file. This will tell Flash the name of the external file we wish to load into the intro swf. In the example, I decided to call the external swf "ecard.swf" and the name of my intro swf is "dCipolloDesigns_Ecard18.swf". You may wish to use different names. If so, make the appropriate changes to the following HTML code.

  5. Open your HTML file into a text editor.

  6. Look for the AC_FL_RunContent JavaScript. It should be about line 300 or so.

  7. Now, we will add the name of the external swf (ecard.swf) to this script. We will add it to the scr and movie parameters in the JavaScript. In the example, the name of my intro swf is "dCipolloDesigns_Ecard18.swf". Therefore, I will add the "ecard=ecard.swf" to the end of this. Remember that I said we would see the parameter "ecard" again from above. Notice that we have removed the ".swf" extension from the end of the intro swf (dCipolloDesigns_Ecard18). We must do this for the JavaScript.


    We need to add this to the src and movie parameters for this script.

  8. Next we will work on the movie param and the object tag. For the movie parameter, we will add the same code. Notice that this time we do not remove the ".swf" at the end of the name for our intro swf.


  9. The last place that we need to add this code is for the embed tag and the src parameter. Again we keep the ".swf".


  10. The last thing we need to do is add a stop(); code on Frame 150. Right-click on Frame 150 and Insert a Keyframe. Open the Actions panel and type "stop();". Now you can test your movie.

    Note. If you test your project within the Flash work environment, you will get an error. So we need to test our finished project by using the HTML file.

← Back

Join us in the Flash forum.

Add ActionScript+to+Load+External+SWF to Twitter Add ActionScript+to+Load+External+SWF to Facebook Add ActionScript+to+Load+External+SWF to MySpace Add ActionScript+to+Load+External+SWF to Digg ActionScript+to+Load+External+SWF Add ActionScript+to+Load+External+SWF to Yahoo My Web Add ActionScript+to+Load+External+SWF to Google Bookmarks Add ActionScript+to+Load+External+SWF to Stumbleupon Add ActionScript+to+Load+External+SWF to Reddit


RSS | Related Articles | Editor's Picks Articles | Top Ten Articles | Previous Features | Site Map

For FREE email updates, subscribe to the Flash and Animation Newsletter

Past Issues

Printer Friendly
tell friend
Tell a Friend
Email Editor

Content copyright © 2018 by Diane Cipollo. All rights reserved.
This content was written by Diane Cipollo. If you wish to use this content in any manner, you need written permission. Contact Diane Cipollo for details.


g features
Subtle Animation Website Trends

Wix Editor - Background Video

Video on Wix Websites

Archives | Site Map


Past Issues

Note: BellaOnline uses cookies to help provide a consistent user experience. Our advertisers may use cookies to help customize ads. Please contact us with any question about our cookie use.

Summertime Foods
Corn on the Cob
Burgers on the Grill
Apple Pie


| About BellaOnline | Privacy Policy | Advertising | Become an Editor |
Website copyright © 2018 Minerva WebWorks LLC. All rights reserved.

BellaOnline Editor