Hi Pranav

> Well Luke,
> I am not much into the theory of OOPs, but it seems that you are wrong
> about the object reference being erased when the timeout is forgotten. You
> will need to assign the object to a variable by using a return statement
> and explicitly set the variable to void later.

Actually Pranav, you don't explicitly need to return anything to keep the
object alive. All you need to keep an object alive is to keep a reference to
that object. The return statement normally used during the on new handler is
used to return a reference that you can store in a variable ... forgetting
to  return the object reference generally causes an object to commit suicide
instantly after creation. But you can still store a reference by assigning
it to another source such as what Luke is doing by stuffing the reference
into the target of a timeOut object. Other such methods can be stuffing the
object reference into a things like the scriptInstanceList of a sprite etc..

 The timeout is a
> property of
> the object, not the object itself. An object can have a property that is
> void. So deleting the timeout does not free up space taken up by the
> object.

A timeOut object, is itself a special object, whose reference is stored in
the timeOutList. It has a several properties: target, period, etc... Luke is
only internally storing a reference to the string name of the timeOut object
in his other object, thus there should be no cross reference. Now if
Director has a bug that maintains the reference to the target of a timeOut
object even after the timeOut object is removed from the timeOutList then a
memory leak could potentially occur. The only surefire method of killing the
object would then be to forcibly void the target of the timeOut object
before forgetting the timeOut object.

> As far as I know, erasing the reference to the object isn't done
> internally. Objects dont commit suicide!!! :-)

An object ceases to exist and should automatically be garbage collected when
all references to that object are removed. So provided that all references
to that object are removed, it should die, included in that situation when
an object which holds a reference to another object in a property is
dereferenced, both objects should cease to exist, although for safety, its
often wise to manually void the appropriate properties /variables.

Sincerely

Mark

--------------------------------------------
Mark R. Jonkman
Mark R. Jonkman Consulting
ADDRESS: 20 Windermere Crt., Guelph, ON, CANADA N1E 3L4
PHONE: 519-837-8509
EMAIL: [EMAIL PROTECTED]
--------------------------------------------


[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/LUJ/lingo-l.cgi  To post messages to the list,
email [EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED])
Lingo-L is for learning and helping with programming Lingo.  Thanks!]

Reply via email to