Hi,
I’m having problems with the removeEventListener function; it doesn’t do anything for some reason.
Here are some snippets of my code (the things that were cut out can’t have anything to do with this since they don’t get called or anything when this problem occurs):
class ProjectileWeapon extends Sprite
{
[...]
public function new()
{
super();
trace("tadaa");
y = Global.elementSize * 2;
graphics.beginFill(0x000000);
graphics.drawRect(0, 0, 0.8 * Global.elementSize, 0.8 * Global.elementSize);
this.addEventListener(Event.ENTER_FRAME, update);
}
[...]
public function remove():Void {
this.removeEventListener(Event.ENTER_FRAME, update);
this.parent.removeChild(this);
}
}
For some reason, when calling the remove function, the instance gets removed, but the eventListener stays right where it is. Using Google, I found out that in flash removing an eventListener only works in the same function as the addEventListener, and I’m compiling to flash. Using the same function for both doesn’t work with me, but maybe this problem is similar?