For display objects, another option could be using the ADDED_TO_STAGE and REMOVED_FROM_STAGE events to initialize and destroy the object. In many cases, at least. In some others, especially if initialization is expensive, it could be better to have explicit methods for that. But I think in the general case, using those events simplifies the interface (meaning, the user of the class doesn't have to bother calling a destroy method, etc).
Cheers Juan Pablo Califano ---------- Forwarded message ---------- From: Matt S. <[email protected]> Date: 2010/1/6 Subject: Re: [Flashcoders] Best MovieClip removal practice To: Flash Coders List <[email protected]> Not only is it better, but definitely best practice. The most basic method is to include a listener destroyer function within the class so that it can deactivate itself before being removed, eg: SomeMovieClip.destroyMe(); removeChild(SomeMovieClip); SomeMovieClip = null; there are fancier ways to handle this of course but thats the basic concept. http://www.almogdesign.net/blog/actionscript-3-event-listeners-tips-tricks/ .m On Wed, Jan 6, 2010 at 5:19 PM, ktt <[email protected]> wrote: > Hello, > > After > > removeChild(SomeMovieClip); > SomeMovieClip = null; > > it will removed and will wait for garbage collector. > But maybe it is better to remove most unwanted listeners before nullifying the MovieClip and not wait for garbage collector? > It should save some memory space and time for actually "working" MovieClips and Events. > What do you think? > > Ktt > > > > _______________________________________________ > Flashcoders mailing list > [email protected] > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > _______________________________________________ Flashcoders mailing list [email protected] http://chattyfig.figleaf.com/mailman/listinfo/flashcoders _______________________________________________ Flashcoders mailing list [email protected] http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

