AS3 – Cosas que se deben hacer antes de descargar un swfPublicado por Iván Gajate el 11 de enero de 2009 en AS3, Flash
Things You Must Do Before Unloading a SWF File
If you load a .swf file into Flash Player 9 with ActionScript 3.0 and subsequently wish to remove it from memory, you must first deactivate it, and then dereference it. If you dereference the .swf without deactivating it, it will continue to consume resources and in some cases might never become eligible for garbage collection.
Here is an unofficial list of tasks required to deactivate a .swf file:
- Tell any loaded .swf child assets to disable themselves.
- Stop any sounds from playing.
- Stop the main timeline, if it is currently playing.
- Stop any movie clips that are currently playing.
- Close any connected network objects, such as instances of Loader, URLLoader, Socket, XMLSocket, LocalConnection, NetConnections, and NetStream.
- Release all references to cameras and microphones.
- Unregister all event listeners in the .swf (particularly Event.ENTER_FRAME, and mouse and keyboard listeners)
- Stop any currently running intervals (via clearInterval()).
- Stop any Timer objects (via the Timer class’s instance method stop()).
Note that the preceding list is, by definition, insufficient because it is neither exhaustive nor officially maintained by Adobe. If you know of a task that needs adding to the preceding list, please sent it to me via email (username colin, domain moock.org).
As of Flash Player 10, the preceding tasks can be performed automatically by calling the Loader class’s new method unloadAndStop().