Am I making garbage?
Hi,
In certain frames of a MC (Sandal) which I add it to another MC (gamelevel), I run a hitTestObject between it (Sandal) and some other MCs (they are in bArray).
Here in the main class I make the sandal:
public function hitBySandal () {
var sandalH:Sprite = new Sprite();
var sandal:Sandal = new Sandal();
sandal.scaleX = .5;
sandal.scaleY = sandal.scaleX;
sandalH.x = mouseX - sandalH.width;
sandalH.y = mouseY - sandalH.height;
sandalH.addChild (sandal);
gamelevel.addChildAt (sandalH, bArray.length + 1);
}
and here in some sandal's frames I coded:
var mc:MovieClip = MovieClip(this.root); //this.root is my mainclass
addEventListener (Event.ENTER_FRAME, checkHit);
function checkHit (event:Event) {
for (var i:int = 0; i < mc.bArray.length - 1; i++) {
if (this.hitTestObject(mc.bArray)) {
mc.kill (mc.bArray);
}
}
}
I add and remove this eventListener in some other frames where I need to hitTestObject.
1. I need to know if var mc:MovieClip = MovieClip(this.root) is just copying my main class that is a huge scene, and if yes, does it (the memory) completely vanish after removing the sandal?
2. Can I NOT make the mc above and instead work directly with this.root? (it knows this.root BUT not its variables as bArray)
For removing sandal and its holder I coded in its last frame:
stop ();
removeEventListener(Event.ENTER_FRAME, checkHit)
this.parent.parent.removeChild (parent);
So am I doing things right or just making garbage?