Question about setting an array null vs setting each item null in the array and saving memory.
Hello,
I'm trying to avoid any sort of memory leaks or garbage collection problems.
public class test{
var anArray:Array;
.
.
.
public function addObjects(){
anArray = new Array();
anArray[0] = new Something();
anArray[1] = new Something();
anArray[2] = new Something();
for(var i:int = 0; i < anArray.length){
anArray.addEventListener(MouseEvent.CLICK, doSomething);
addChild(anArray);
}
}
private function doSomething(event:MouseEvent){
for(var i:int = 0; i < anArray.length; i++){
anArray.removeEventListener(MouseEvent.CLICK, doSomething);
removeChild(anArray);
}
anArray = null;
}
}
Is this efficient or do I have to include "anArray = null" after "removeChild(anArray)" in the for loop of my doSomething(event:MouseEvent) function?
Sorry if my question is confusing and thank you in advance.