# Loading an external SWF

**URL:** <https://forum.kirupa.com/t/loading-an-external-swf/289503>\
**Category:** flash\
**Created:** [May 31, 2009, 11:09pm UTC](https://forum.kirupa.com/t/loading-an-external-swf/289503 "2009-05-31T23:09:17Z")\
**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:** [May 31, 2009, 11:09pm UTC](https://forum.kirupa.com/t/loading-an-external-swf/289503/1 "2009-05-31T23:09:17Z")

</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.
