Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Movie clip garbage collection As3

New Here ,
May 13, 2016 May 13, 2016

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

TOPICS
ActionScript
266
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 13, 2016 May 13, 2016

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;

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 15, 2016 May 15, 2016

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 15, 2016 May 15, 2016
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines