# Unloading external swf

**URL:** <https://forum.kirupa.com/t/unloading-external-swf/252064>\
**Category:** Uncategorized\
**Created:** [February 15, 2008, 2:10pm UTC](https://forum.kirupa.com/t/unloading-external-swf/252064 "2008-02-15T14:10:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![charlierun](https://avatars.discourse-cdn.com/v4/letter/c/dbc845/32.png) [@charlierun](https://forum.kirupa.com/u/charlierun)\
**Post date:** [February 15, 2008, 2:10pm UTC](https://forum.kirupa.com/t/unloading-external-swf/252064/1 "2008-02-15T14:10:34Z")

</div>

Hi kirupa forum Im doing an application which loads external swf (which I cant edit) into a site.  
So basically you got this gallery of images that when you press them they unload the current swf in the frame and load the new swf into that frame.  
what I have done apparently works but when you this a lot the swf loaded start to run more and more slowly which by using System.totalMemory I realized that basically anything was unloading. here is my unload and load code please help me out cause Im starting to go mental…

```php
	private function onCLick(e:MouseEvent):void{
					var mem:String=Number(System.totalMemory/1024/1024).toFixed(2)
					//trace("memorias"+mem)
			if(loader!=null){
				trace("removing"+mem)
					try { loader.close(); } catch (e:*) {}
					try { loader.unload(); } catch (e:*) {}
					removeChild(loader);
					loader = null;
					flash.media.SoundMixer.stopAll();
					try {
			 		new LocalConnection().connect('foo');
			 		new LocalConnection().connect('foo');
					} catch (e:*) {}
					var mem1:String=Number(System.totalMemory/1024/1024).toFixed(2)
					//trace("memorias"+mem1)
			}
			else{
				loader = new Loader();
				var request:URLRequest = new URLRequest("Player.swf");
				loader.load(request);
				addChild(loader);
			}
		}

```

Im not having any errors but I think nothing is actually unloading If anyone can point me what Im leaving out I will be extremelly gratefull
