Click to See Complete Forum and Search --> : [RESOLVED] Truly deleting a movieclip
Blommestein
05-26-2007, 01:02 PM
Im using a tilebased method, and in it I create movieclips using the new keyword paired with addChild. I want to free all memory used with the movieClips when it is time to delete them, including deleting it off the stage, of course.
Do I use delete, removeMovieClip(), set it to something (null for example), something else, or a combination of some of them?
Thanks. :)
senocular
05-26-2007, 01:07 PM
you use removeChild and delete or null and variables that reference that movie clip. You use delete if the reference is a dynamic variable assigned to a dynamic instance and you use null if the reference is a class property or a non-dynamic property of an inatance (null actually works in both cases so if you're confused about when to use which, use null). This also includes all listeners for that movie clip be removed since a listener counts as a reference.
Event then, however, the movie clip may still take up some memory until the automatic "garbage collector" (or GC) comes through and sweeps up all the trashy memory in player. This could take a while, frames, seconds, or even longer. The best thing you can do is just make it available for cleaning which means removeChild and remove all references.
flashkit.com
Copyright Internet.com Inc., All Rights Reserved.