# Loading external swf's

**URL:** <https://forum.kirupa.com/t/loading-external-swfs/317959>\
**Category:** Uncategorized\
**Created:** [January 6, 2011, 11:28pm UTC](https://forum.kirupa.com/t/loading-external-swfs/317959 "2011-01-06T23:28:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![brenda318](https://avatars.discourse-cdn.com/v4/letter/b/ad7895/32.png) [@brenda318](https://forum.kirupa.com/u/brenda318)\
**Post date:** [January 6, 2011, 11:28pm UTC](https://forum.kirupa.com/t/loading-external-swfs/317959/1 "2011-01-06T23:28:41Z")

</div>

Hi,

I have a main timeline in which 2 external swf’s are loaded. Once the first one is finished, it is removed and replaced by the second one. The problem that i am having, is that I don’t know how to get rid of the second one when it is finished playing. i am very new to AS so please be as explicit as possible. Here is my code so far-

```php
var my_Loader:Loader = new Loader();
my_Loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadComplete);
my_Loader.load(new URLRequest("sc_02_shyamal.swf"));

my_Loader.contentLoaderInfo.addEventListener(Event .COMPLETE, onLoadComplete);
var currentSWF:MovieClip;
 
function onLoadComplete(e:Event):void {
     my_Loader.contentLoaderInfo.removeEventListener(Event.COMPLETE, onLoadComplete);
     currentSWF = MovieClip(e.target.loader.content);
     currentSWF.addEventListener(Event.ENTER_FRAME, onEnterFrame);
     addChild(currentSWF);
}
 
function onEnterFrame(e:Event):void 
{
     if (currentSWF.currentFrame == currentSWF.totalFrames) {
          currentSWF.stop();
          removeChild(currentSWF);
          currentSWF.removeEventListener(Event.ENTER_FRAME, onEnterFrame);
          // if you want to get rid of it altogether
          currentSWF = null;
          my_Loader.unloadAndStop();
          
          my_Loader.load(new URLRequest("sc_08_sujoy.swf"));
          my_Loader.contentLoaderInfo.addEventListener(Event .COMPLETE, onLoadComplete);
          
     }
}

```

Thanks.
