Adobe has announced the addition of the new Loader.unloadAndStop() method for Flash Player 10. Here is the description from the beta 2 release notes:


unloadAndStop — This new ActionScript 3.0 API adds unload functionality similar to the unload behavior in ActionScript 2.0. After calling unloadAndStop on loaded content it will be immediately removed stopping all audio, removing eventListeners, and becoming inaccessible through ActionScript.

This new API addresses some of the issues I raised in my article "Failure to Unload: Flash Player 9's Dirty Secret". It doesn't enable content sandboxing, or provide a complete mechanism for explicit unloading, but it does make it much simpler to free a loaded SWF for garbage collection. It's still possible to prevent a SWF from being unloaded, but it's much more difficult to do by accident.

Kudos to the player team for putting this in. If you're concerned about this topic, please help Adobe out by testing this feature and reporting any problems.


Update: You can find more details on the Loader.unloadAndStop feature in my article "Additional Information on Loader.unloadAndStop".