Well, I'll be darned.

var a:Object = new Object();
var b:Object = a;
a.toString = function():String {
        return "object";
}
trace(a + ", " + b);
delete a;
trace(a + ", " + b);

Output:
object, object
undefined, object

Is there any difference at all between deleting a variable and setting
it to undefined?
―
Mike Keesey

> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:flashcoders-
> [EMAIL PROTECTED] On Behalf Of Peter Hall
> Sent: Tuesday, October 03, 2006 3:55 PM
> To: Flashcoders mailing list
> Subject: Re: [Flashcoders] when classes die...
> 
> > public function destroy():Void {
> >         // Perform clean-up.
> >         delete this;
> > }
> 
> 
> This code is garbage. The delete operator operates on variables and
> not on values. So "delete this" will just delete a variable called
> "this" within the scope of that function. To remove an object from
> memory, you have to remove all references to it. And you can do that
> by using delete on each one of those references, or by setting those
> variables to some other value.
> 
> Peter
> _______________________________________________
> [email protected]
> To change your subscription options or search the archive:
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> 
> Brought to you by Fig Leaf Software
> Premier Authorized Adobe Consulting and Training
> http://www.figleaf.com
> http://training.figleaf.com

_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to