function deleteClasses(classInstance){
        for(var i in classInstance){
                if(typeof classInstance[i] == "function"){
                        delete model[i];
                }else if(typeof classInstance[i] == "object"){
                        deleteClasses(classInstance[i]);
                }
        }
}



Date: Tue, 6 Dec 2005 09:22:00 +1100
From: "rob costello"
<[EMAIL PROTECTED]>
Subject: [Flashcoders] RE: How to make a class
instance
        self-destructible?
To: <[email protected]>
Message-ID:

<[EMAIL PROTECTED]>
Content-Type: text/plain;       charset="us-ascii"

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



                
__________________________________________ 
Yahoo! DSL – Something to write home about. 
Just $16.99/mo. or less. 
dsl.yahoo.com 

_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to