# Load SWF at enterFrame

**URL:** https://forum.kirupa.com/t/load-swf-at-enterframe/265029
**Category:** flash
**Created:** [July 3, 2008, 4:27am UTC](https://forum.kirupa.com/t/load-swf-at-enterframe/265029 "2008-07-03T04:27:29Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![slimpickinz](https://avatars.discourse-cdn.com/v4/letter/s/5f8ce5/32.png) [@slimpickinz](https://forum.kirupa.com/u/slimpickinz)
#### Post date: [July 3, 2008, 4:27am UTC](https://forum.kirupa.com/t/load-swf-at-enterframe/265029/1 "2008-07-03T04:27:29Z")

</div>

I have this page that I want to auto load the “HOME” mc.  
From there I want the buttons to navigate the page.  
I have got the buttons to work properly so far, but cannot for the life of me figure out how to load the HOME swf, then unload it with the same removeChild as the rest of the buttons do…  
Here is what works…

```auto
 
var thisLoader:Loader = new Loader();
thisLoader.contentLoaderInfo.addEventListener(Event.INIT, doneLoading);
var thisMC:MovieClip = new MovieClip();
stage.addChild(thisMC);// Add empty MC initially so the nextClip function can be generic
// Tell AS that the loaded file is a movie clip and add it to the stage.
function doneLoading(e:Event):void {
    stage.removeChild(thisMC);
    thisMC = MovieClip(thisLoader.content);
    thisLoader.unload();
    stage.addChild(thisMC);
 thisMC.x = 60;    
    thisMC.y = 300;
    thisMC.play();
}
// "BTN_#" just calls a function that goes to the next file name
btnHome.addEventListener(MouseEvent.CLICK, play1);
function play1(e:MouseEvent):void {
    thisLoader.load(new URLRequest("./mcClips/mc1.swf"));
}
btnAbout.addEventListener(MouseEvent.CLICK, play2);
function play2(e:MouseEvent):void {
    thisLoader.load(new URLRequest("./mcClips/mc2.swf"));
}
 
btnFAQ.addEventListener(MouseEvent.CLICK, play3);
function play3(e:MouseEvent):void {
    thisLoader.load(new URLRequest("./mcClips/mc3.swf"));
}
btnPolicies.addEventListener(MouseEvent.CLICK, play4);
function play4(e:MouseEvent):void {
    thisLoader.load(new URLRequest("./mcClips/mc4.swf"));
}
 

```

Can someone please assist me on this, once I get past this point I have got the rest figured out.  
Thanks  
-SlimP

---

<div class="post-metadata">

### Author: ![Lida\_Tang](https://avatars.discourse-cdn.com/v4/letter/l/58956e/32.png) [@Lida\_Tang](https://forum.kirupa.com/u/Lida_Tang)
#### Post date: [July 3, 2008, 5:02am UTC](https://forum.kirupa.com/t/load-swf-at-enterframe/265029/2 "2008-07-03T05:02:12Z")

</div>

The code you posted shows an empty MC initially. Your problem is that if you were to load a ‘home.swf,’ doneLoading callback wouldn’t correctly start the home MC?

How are you loading the home MC initially? Because it should work as the rest of your pages.

---

<div class="post-metadata">

### Author: ![slimpickinz](https://avatars.discourse-cdn.com/v4/letter/s/5f8ce5/32.png) [@slimpickinz](https://forum.kirupa.com/u/slimpickinz)
#### Post date: [July 3, 2008, 11:29am UTC](https://forum.kirupa.com/t/load-swf-at-enterframe/265029/3 "2008-07-03T11:29:06Z")

</div>

Here is the basic movie…Please take a look and see what you think.  
I want clip1.swf (HOME) to automatically load upon start, you say I should just replace the empty clip with this one then?  
[http://www.downeydesign.com/docs/external\_swf.zip](http://www.downeydesign.com/docs/external_swf.zip)

thanks!  
-SlimP

---

<div class="post-metadata">

### Author: ![Lida\_Tang](https://avatars.discourse-cdn.com/v4/letter/l/58956e/32.png) [@Lida\_Tang](https://forum.kirupa.com/u/Lida_Tang)
#### Post date: [July 3, 2008, 3:03pm UTC](https://forum.kirupa.com/t/load-swf-at-enterframe/265029/4 "2008-07-03T15:03:03Z")

</div>

It should just be

```auto

var thisLoader:Loader = new Loader();
thisLoader.contentLoaderInfo.addEventListener(Event.INIT, doneLoading);
var thisMC:MovieClip = new MovieClip();
stage.addChild(thisMC);// Add empty MC initially so the nextClip function can be generic
// load home
thisLoader.load(new URLRequest("./clip1.swf"));

```

---

<div class="post-metadata">

### Author: ![slimpickinz](https://avatars.discourse-cdn.com/v4/letter/s/5f8ce5/32.png) [@slimpickinz](https://forum.kirupa.com/u/slimpickinz)
#### Post date: [July 3, 2008, 11:56pm UTC](https://forum.kirupa.com/t/load-swf-at-enterframe/265029/5 "2008-07-03T23:56:30Z")

</div>

That did it!  
I tried several variations before, but as I sometimes do, I make it more complicated than I should.  
Thanks again!  
-SlimP

:bounce:
