# Loading an external SWF

**URL:** https://forum.kirupa.com/t/loading-an-external-swf/289507
**Category:** Uncategorized
**Created:** [June 1, 2009, 1:49am UTC](https://forum.kirupa.com/t/loading-an-external-swf/289507 "2009-06-01T01:49:54Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![steresa](https://avatars.discourse-cdn.com/v4/letter/s/e68b1a/32.png) [@steresa](https://forum.kirupa.com/u/steresa)
#### Post date: [June 1, 2009, 1:49am UTC](https://forum.kirupa.com/t/loading-an-external-swf/289507/1 "2009-06-01T01:49:54Z")

</div>

I know how to load an external swf file with the following AS3

var req:URLRequest = new URLRequest(“[http://www.beholdcreative.com/slide\_home.swf](http://www.beholdcreative.com/slide_home.swf)”);

var loader:Loader = new Loader();

loader.load(req);  
addChild(loader);

loader.x = -442;  
loader.y = -194;

However, I want to load an external swf that is triggered by a mouse click. I have a button with an instance name if photogallery\_btn and I want to apply AS3 to this so when this button is clicked, an external swf is loaded. Can some one please show me how to right this code?

Also, how do you unload a external swf? For example, say I get the code working for the photogallery\_btn so when it’s clicked, an external swf file is loaded. I would like to know how to unload another external swf file once the photogallery\_btn is clicked.
