Re: [Flashcoders] Can an object delete itself?

2005-12-23 Thread Judah Frangipane
Mark Burvill wrote: public function die():Void { trace (deleting); removeMovieClip (baddie_mc); delete this; trace (Am i still alive?); } The movieclip is successfully removed, but I would expect the second trace Am I still alive NOT to appear as the object

RE: [Flashcoders] Can an object delete itself?

2005-12-23 Thread Steven Sacks
delete something that garbage collection would take over after the function exits. Someone correct me if I'm wrong. Yes, you can do that with Flash methods like onEnterFrame, but not objects. Notice, just because you delete an object like that and it doesn't respond to methods that cause a

Re: [Flashcoders] Can an object delete itself?

2005-12-21 Thread Andreas Rønning
Mark Burvill wrote: Hi all, I've just started transitioning to AS2 (so go easy on me), and have a question about a game I'm building... I have a Baddie object which handles a baddie on the screen, and when one gets killed, and has finished it's death animation, I'm running a method within

Re: [Flashcoders] Can an object delete itself?

2005-12-21 Thread Jordan L. Chilcott
Legal or not, it's very unwise to let an object kill itself. Letting an object commit suicide would leave the rest of a program in a lurch as it wouldn't really know where to go from there. You haven't officially returned back to the caller at that point. You are better off sending out an

Re: [Flashcoders] Can an object delete itself?

2005-12-21 Thread Mark Burvill
Nice one - thanks Andreas. :o) Andreas Rønning wrote: Mark Burvill wrote: Hi all, I've just started transitioning to AS2 (so go easy on me), and have a question about a game I'm building... I have a Baddie object which handles a baddie on the screen, and when one gets killed, and has

Re: [Flashcoders] Can an object delete itself?

2005-12-21 Thread Cedric Muller
maybe I am just thinking out loud (and my mind is a tricky one) but, don't you delete an object's instances and not directly the class itself (how could it delete itself ?) ? like: var baddieInstance = new Baddie(); ... later ... baddieInstance.die(); // internal deletion process (like

RE: [Flashcoders] Can an object delete itself?

2005-12-21 Thread Steven Sacks
If you're going to constantly be creating enemies, you might want to simple do a check of existing enemies and if an enemy is dead, delete it when you create one. The important thing to note is that an enemy cannot call the destroyEnemy() method of its manager because then it's still the same