Here's an example I came across this morning that has helped me to cut back on my ram waste
http://livedocs.macromedia.com/flash/mx2004/main_7_2/wwhelp/wwhimpl/common/html/wwhelp.htm?context=Flash_MX_2004&file=00002401.html On 4/27/06, Julien Vignali <[EMAIL PROTECTED]> wrote: > > Hi guys, > I am getting memory problems when I remove and recreate all my objects > several times (the flash player eats up RAM, and I have to minimize it > and maximize to force the garbage collector).There must be something > wrong in the way I destroy my objects :-( > > So I am wondering what is the best way to handle event listeners and to > be able to remove the listeners afterwards in order to avoid memory > waste... > > I've seen on some page that using Delegate (or Lott's Proxy class) is a > good practice, but how do you properly remove the listener when you're > done with the object ? > > For example in class A (see below), how do you remove "this" from > listening to every elements' "myevent" event in the destroy() method ? > > Thanks! > Julien > > > public classA extends MovieClip { > > public function addElement(data:Object):Void { > var elt:CustomMC = attachMovie("Test", "test"+data.id, > getNextHighestDepth()); > elt.addEventListener("myevent", Delegate.create(this, > this.onMyEvent)); > elements[data.id] = elt; > } > > public function destroy():Void { > for(var i:String in elements){ > var elt:CustomMC = elements[i]; > // remove listener object... ??? > elt.removeMovieClip(); > elements[i] = null; > } > } > > private function onMyEvent(event:Object):Void { > // handle the event... > } > } > > > > > _______________________________________________ > [email protected] > To change your subscription options or search the archive: > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > > Brought to you by Fig Leaf Software > Premier Authorized Adobe Consulting and Training > http://www.figleaf.com > http://training.figleaf.com > _______________________________________________ [email protected] To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com

