title: How do I completely remove a loaded swf and reload it? (Trying to restart a game)
body: <p>I have a preloader that loads a swf, the swf creates a bunch of listeners, objects, and movie clips.  I want all of these to be destroyed and recreated.</p>
  
  <p>Simplified version of my preloader:</p>
  
  <pre><code>var request:URLRequest = new URLRequest("myfile.swf");
  var myLoader:Loader = new Loader();
  var urlLoader:URLLoader = new URLLoader();
  
  
  urlLoader.addEventListener(Event.COMPLETE, function(event){ 
      stage.addChild(myLoader);
      myLoader.loadBytes(urlLoader.data);
  });
  
  urlLoader.dataFormat = URLLoaderDataFormat.BINARY;
  urlLoader.load(request);
  </code></pre>
  
  <p>When I try to remove it, I do this:</p>
  
  <pre><code>stage.removeChild(myLoader);
  var child = loader.myLoader.content as Object;
  SoundMixer.stopAll();
  while(stage.numChildren &gt; 0){
       stage.removeChildAt(0);
  }
  child.stop();
  while(stage.numChildren &gt; 0){
       stage.removeChildAt(0);
  }
  child=null;
  
  System.gc();
  myLoader.unloadAndStop(true);
  System.gc();
  myLoader.unload();
  System.gc();
  myLoader.loadBytes(urlLoader.data);
  stage.addChild(loader.myLoader);
  </code></pre>