PDA

View Full Version : Deleting a class/sprite



skimmmer
April 6th, 2008, 01:56 AM
Hi,

I made a class (which extends sprite) that has a game I created in it, I add it using:


gameS:Game = new Game(this.stage,mp3,id);But when I use:


delete this;
this.parent.removeChild(this);(inside the class), it is not visible but functions inside are still operating. This is a public class with public vars. Am I using the wrong type for the class or am I deleting and removing the class/sprite incorrectly?

Thanks!

Felixz
April 6th, 2008, 05:50 AM
deleting of objects is done automatically
delete this won't do anything. U should set all references to ur object to null or replace by something else and remove all eventListeners which aren't weak.

substance
April 6th, 2008, 05:52 AM
removeChild just removes the object from the display list.

I think the 'delete' keyword only works with non-member variables. So im guessing when all references to an instance are gone AS3's GC will eventually get rid of it... not sure though.

Felixz
April 6th, 2008, 06:29 AM
delete just removes dynamic properties

skimmmer
April 6th, 2008, 02:25 PM
Thanks! I think it was the event listeners that were causing the problem, so I'll remove them with removeEventListener().