# Remove Dynamically-Added .swf

**URL:** <https://forum.kirupa.com/t/remove-dynamically-added-swf/228145>\
**Category:** flash\
**Created:** [June 5, 2007, 6:21pm UTC](https://forum.kirupa.com/t/remove-dynamically-added-swf/228145 "2007-06-05T18:21:19Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![douglaae](https://avatars.discourse-cdn.com/v4/letter/d/c89c15/32.png) [@douglaae](https://forum.kirupa.com/u/douglaae)\
**Post date:** [June 5, 2007, 6:21pm UTC](https://forum.kirupa.com/t/remove-dynamically-added-swf/228145/1 "2007-06-05T18:21:19Z")

</div>

Hi folks. I have an AS3 app that allows users to pick from a menu of AS2 .swf movies to load into a MovieClip. Users are allowed click to view one movie, but if they change their mind and click a different clip, it should unload/delete/remove the .swf that’s currently playing so that the user don’t have overlapping movies playing at once. If someone can help me to accomplish this, I would appreciate it! Here’s what I’ve come up with, but it doesn’t work:

try {  
//(see the load code below) If a .swf is already loaded, remove it  
var clipToDelete:Loader = Loader(parentClip.getChildAt(0));  
parentClip.removeChild(clipToDelete);  
clipToDelete = null;  
}  
catch (e) {  
}

//Load a .swf into parentClip  
var loader:Loader = new Loader();  
parentClip.addChild(loader);  
loader.addEventListener(Event.ADDED, parentClipOnLoad);  
loader.load(new URLRequest(“someMovie.swf”);

Thanks!

Andy
