At 3:40 PM -0500 1/18/01, Ian Jempson wrote:
>I have a parent script for the connection to my back end application
>server. Up till now I have been creating a new instance of that object and
>storing it in a global variable. I have just read about the actorlist (I'm
>new to Director so I keep discovering these things) and now my current
>thinking is that I should add it to the actorlist so it can receive the
>stepframe message.
>
>Should I carry on using:
>
>set gPSConnection=new(script "cPSConnection")
>add the actorlist,gPSConnection
>
>or
>
>instead should I be using:
>add the actorlist,new (script "cPSConnection")?
>
>I would like to be able to refer to the object by name instead of refering
>to the index in the actorlist since the code will be easier to read and we
>have several programmers who may be working on it.
>
>Also does: the actorlist=[] set all objects in the actorlist to VOID? If so
>does this include any objectss that were in existence prior to being added
>to the actorlist?
>

Yes, you're doing just fine.  If you want to get the stepFrame 
message, then you need to add your object explicitly to the 
actorList.  You can do this exactly as you specify above still have 
your global variable available to you and other programmers.  One 
other option is for the object to add itself to the actorList - but 
there is really no difference:

    on new me
      ...  any set up code
      add(the actorList, me)
      return me
    end

If you set the actorList = [], this will not neccessarily clear your 
object.  Here's why.  When you create the object, you are storing the 
object reference in a global (gPSConnection).  If you add that object 
reference to the actor list, you are in effect, making a copy of the 
object reference.  So now there are two things that point to that 
object.  If you clear the actorList, the number of things that point 
to the object drops back down to one.  If you set the global variable 
to VOID (or zero), then the object will really go away because its 
"reference count" will go down to zero, a signal to Director that 
nobody needs this object anymore and Director can "garbage collect" 
it.

Good luck,

Irv
-- 
Lingo / Director / Shockwave development for all occasions.

        (Over two millions lines of Lingo code served!)

[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