Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Clearing memory is a tricky thing with Flash, the proper way ow implementing it setting up objects properly in the first play for easy clearing, rather than forcing deletion. When you want to remove an object from memory, you do it by removing any reference to it, and then flash marks it for garbage collection. Then Flash at a later point removes the object from memory.</p> <p>In order for the object to be ready for data collection it cannot have any connection to another object.</p> <p>so if you have an object that has a single connection to a MovieClip and the movie clip has no other relation, then if you set it to null, you will remove it.</p> <p>if you, however, have two objects that point to it, if you remove one link by setting it to null, the MovieClip will not be removed.</p> <p>furhtermore, if you have a 2 or more movie clips that have a network of connections, removing those objects requires these connections be broken as-well. For example if you have a level with many characters and listeners set up, removing the lavel movieClip will not clear it.</p> <p>one way of breaking these connections is adding onRemovedFromStage Events, that remove further children, listeners and objects. I've started using the <a href="http://casalib.org/" rel="nofollow">casaLib</a> extension of movieclip - <a href="http://as3.casalib.org/docs/org_casalib_display_CasaMovieClip.html" rel="nofollow">CasaMovieClip</a>, that has a function called <a href="http://as3.casalib.org/docs/org_casalib_display_CasaMovieClip.html#removeChildrenAndDestroy" rel="nofollow">removeChildrenAndDestroy</a>. this makes it a bit easier, but would take a while to implement on an older project.</p> <p>Anyhow, you'll find there are many sites discussing this, a good place to start is <a href="http://gskinner.com/blog/archives/2006/06/as3_resource_ma.html" rel="nofollow">grant skinner's blog</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload