On a related note, I'd be interested to know what people make of
destroyObject method in the V2 components   ie UIObject.destroyObject() 
I've had no luck using it to clear component instances
does a component instance call it on itself, as the syntax seems to
suggest; or call it on another instance? 

componentInstance.destroyObject(instanceName)

either way it doesn't unload the instance for me; I end up unloading
components with unloadMovie,  setting variables to null, and sometimes
loading empty mc's into the component depth ... all of which feel like
hacks since I can't get the obvious method to work properly

thanks for remedial advice 

Rob 

On 12/3/05, Boon Chew <[EMAIL PROTECTED]> wrote:
> I am trying to get a class to destroy itself, calling delete obj looks
too unnatural, amidst all OO code.
>
>   Could someone explain why the following doesn't work?
>   The following code doesn't work, is there another way to achieve
this?  Also,
>
> class A
> {
>    function destroy()
>    {
>       delete this;  // doesn't delete itself
>    }
> }
>
> var a = new A();
> delete a;  // delete works here

'delete' only removes the reference, not the actual object. There is
no way to actually destroy an object. All you can do is remove all
references to it, and wait for the GC to remove it from memory at some
unspecified time.

var obj = {data:5};
var obj_ref = obj;
obj_ref.data = 6;

// this proves that it's a reference, and not a copy: both show the same
// value, even though I only changed one
trace(obj.data); // 6
trace(obj_ref.data); // 6

// delete the reference
delete obj;

// as you can see, the object itself was not deleted, only that
// particular reference.
trace(obj.data); // undefined
trace(obj_ref.data); // 6


-David R



Important - 
This email and any attachments may be confidential. If received in error, 
please contact us and delete all copies. Before opening or using attachments 
check them for viruses and defects. Regardless of any loss, damage or 
consequence, whether caused by the negligence of the sender or not, resulting 
directly or indirectly from the use of any attached files our liability is 
limited to resupplying any affected attachments. Any representations or 
opinions expressed are those of the individual sender, and not necessarily 
those of the Department of Education & Training.
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to