And within the removeEventListener, shouldn’t it say zombie instead of enemy?
Because what I imagine is that:
if(zombie) then
zombie.x = zombie.x + 2
end
Is inside the enterFrame callback, right? and it is operating over a removed zombie object. When you call removeSelf() the object does not become nil, but some of it’s entries do, (like removeSelf and x among others)
after you removed it. Reason for doing it this way is that you will release it from memory as well (if there are no other references to this object). This is correct way to remove objects. Unless you have some reason to keep zombie in memory afret you removed it I suggest you do it this way. You can check it the way you had it before: