Get rid of loaded assets when you’re done with them.


Note: This requires Flash Player 10.

SWF files loaded into Flash can sometimes still exist after they have been removed from the stage. The is cause by teh way Flash cleans up elements. If an element is referenced by another object Flash figures it’s still in use and should no be removed.

In some cases this can work to your advantage. Imagine you have a dialog box that appears on the stage periodically to set options in your application. You can remove it from the display list, and then add it to the display list at a later time and have it in tact with all of it’s elements in the same state.

In other cases this can be a problem. For example you load an swf and then you remove it from the stage, but it still takes up RAM and might even still be running it’s enter frame or other events in the background.In this case it’s hurting the efficiency of your application.

The unloadAndStop() method tries to solve this by stopping all actions running in a loaded element and clearing the element out of RAM. The unloadAndStop() methos belongs to the Loader class. The idea is to call this method on your Loader instance to clean what you have loaded.

Leave a Reply

Your email address will not be published. Required fields are marked *