# Loading external swfs into a container

**URL:** <https://forum.kirupa.com/t/loading-external-swfs-into-a-container/309590>\
**Category:** flash\
**Created:** [May 19, 2010, 8:31am UTC](https://forum.kirupa.com/t/loading-external-swfs-into-a-container/309590 "2010-05-19T08:31:28Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![stein\_olsen](https://avatars.discourse-cdn.com/v4/letter/s/85e7bf/32.png) [@stein\_olsen](https://forum.kirupa.com/u/stein_olsen)\
**Post date:** [May 19, 2010, 8:31am UTC](https://forum.kirupa.com/t/loading-external-swfs-into-a-container/309590/1 "2010-05-19T08:31:28Z")

</div>

I have an empty movie instance called ‘contentClip’ sitting in an swf called ‘middle’ on the main timeline. I have a number of buttons to call external swfs into the contentClip but I’m struggling with the exact script.

I am creating a fluid layout so I am using an actionscript file to place the header, footer and middle sections.

The script I have for the buttons follows but my poor knowledge is creating a new instance rather than filling my contentClip instance.

Any help would be appreciated.

var swf:MovieClip;  
var loader:Loader = new Loader();

var defaultSWF:URLRequest = new URLRequest(“content/jamie.swf”);

loader.load(defaultSWF);  
addChild(loader);

function btnClick(event:MouseEvent):void {

```
removeChild(loader);
var newSWFRequest:URLRequest = new URLRequest("content/" + event.target.name + ".swf");
loader.load(newSWFRequest);
addChild(loader);

```

}

jamie.addEventListener(MouseEvent.CLICK,btnClick);  
observation.addEventListener(MouseEvent.CLICK,btnClick);  
who.addEventListener(MouseEvent.CLICK,btnClick);  
wild.addEventListener(MouseEvent.CLICK,btnClick);  
living.addEventListener(MouseEvent.CLICK,btnClick);  
kate.addEventListener(MouseEvent.CLICK,btnClick);  
electric.addEventListener(MouseEvent.CLICK,btnClick);  
self.addEventListener(MouseEvent.CLICK,btnClick);  
portraits.addEventListener(MouseEvent.CLICK,btnClick);  
character.addEventListener(MouseEvent.CLICK,btnClick);  
people.addEventListener(MouseEvent.CLICK,btnClick);  
monkeys.addEventListener(MouseEvent.CLICK,btnClick);  
random.addEventListener(MouseEvent.CLICK,btnClick);  
jamie2.addEventListener(MouseEvent.CLICK,btnClick);  
kate2.addEventListener(MouseEvent.CLICK,btnClick);
