title: How do I unload a externally loaded SWF file from a SWFLoader component in Adobe Flex?
body: <p>I have an application that loads external SWF files and plays them inside a Adobe Flex / Air application via the <a href="http://livedocs.adobe.com/flex/3/html/controls_15.html" rel="nofollow noreferrer">SWFLoader Flex component</a>. I have been trying to find a way to unload them from a button click event. I have Google'd far and wide and no one seems to have been able to do it without a hack. The combination of code I see people use is:</p>
  
  <pre><code>swfLoader.source = ""; // Removes the external link to the SWF.
  swfLoader.load(null); // Forces the loader to try to load nothing.
  // Note: At this point sound from the SWF is still playing, and
  // seems to still be playing in memory.
  flash.media.SoundMixer.stopAll();
  // Stops the sound. This works on my development machine, but not 
  // on the client's.
  </code></pre>
  
  <p>If the SWFs are closed (hidden) this way, eventually the program crashes.</p>
  
  <p>Any ideas? I have found tons of posts in various forums with people having the same problem. I assume I will get one wrong/incomplete answer here, and than my post will sink into nothingness as usual, but either way, thanks in advance!</p>
  
  <p><em>Edit 1</em>:  I can't edit the actual SWF movies, they're created by the client. If I can't close any SWF opened through Flex, isn't that a problem with the Flex architecture? Is my only option sending the SWFs to the web browser?</p>