Copy link to clipboard
Copied
Hi guys,
I'm new to AS3 and I'm working on this game that involves several movie clips playing one right after the other and everything works great so far but I'm not sure it was wise of me to make the movie clips using image sequences and now I have this issue of RAM usage. Is there a way to clear the RAM using the garbage collection when the clip has finished playing and is no longer needed? As it is the game plays and the RAM just keeps adding up until it gets to around 12gb and crashes so clearly not ideal. Any ideas?
Thanks in advance
Alex
Copy link to clipboard
Copied
to allow animate pro to gc a movieclips you need to remove it from the display, remove all its listeners and null all its references. eg, for
var mc:MovieClip=new MovieClip();
addChild(mc);
mc.addEventListener(MouseEvent.CLICK,f);
// you need to execute the following to enable mc to be gc'd:
removeChild(mc);
mc.removeEventListener(MouseEvent.CLICK,f);
mc=null;
Copy link to clipboard
Copied
Oh thank you!!! I think I get it. So is making it a child necessary? Currently I don't have any of my movie clips set as children. I just initialised then from an array. So can I not set the mc=null if it isn't a child?
Copy link to clipboard
Copied
you don't have to add movieclips as children, but if they are never children, they're never shown.
further, if you create movieclips on the stage in the ide, those movieclips are children and must be removed from the display and all references to them must be nulled before they are eligible for gc.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now