actionscript 3 - Removing object from the display list -


i have application uses main class control other movieclips, adding , removing them needed, of them separate screens or sub menus.

when leave main menu , come later screen, animations , roll on buttons still play, don't want, need main menu screen reset every time seen.

i read on , found out removing child doesn't remove memory.

i tried setting mainmenu null before moving onto different screen threw error, stating parameter child must none null.

could shed light on how kill mainmenu when not needed.

public function confsubmenuonescreen():void {         submenuonescreen = new submenuone();         mainmenu = null;         removechild(mainmenu)         addchild(submenuonescreen)         currentscreen = submenuonescreen;     } 

this example of code removes menu , adds screen, mainmenu = null code throws error.

the error you're getting because you're setting object null - attempting remove object (which null). reversing 2 lines fix error. however, won't free object memory until garbage collection removes (assuming there no other references "mainmenu" in application).

rather trying delete object , create new objects each time need it, suggest creating 1 instance of "mainmenu" , reuse it. then, remove display list , add when need again.


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -