The basic difference is this:

Behaviors are intended to be "attached" to sprites.  When the 
playhead enters the begining of a sprite span that has a behavior 
attached, Director calls the "on beginSprite" handler in the 
behavior.  Inside a behavior, you can also code up a special handler 
called "on getPropertyDescriptionList", that allows you - at 
authoring time - to set the value for properties used in the 
behavior.  The settings of these property values are saved in the 
score.  This way, the same behavior can be used in multiple places, 
and you can have different initial values for any or all properties 
in the behavior (as defined by your getPropertyDescriptionList). 
When the playhead reaches the end of a sprite span, Director calls 
the "on endSprite" handler.

Parent scripts are not intended to be "attached" to sprites.  A 
programmer creates an object explicitly from a parent script by 
calling the "new" handler in the script.  The "new" handler in the 
parent script typically looks like this:

   on new me <, someOptionalParameters>
     -- any initialization code you want to have
     return me  -- this returns the object reference "me"
   end

You create an object by executing a line of code like this:

    someObjectReference = new(script "SomeParentScript", 
<someOptionalParameters>)

This returns the "object reference" to the newly created object. 
Whenever you want to call any of the handlers in the object, you must 
supply this object reference, for example

    mDoSomething(someObjectReference, <someOptionalParameters>)

This calls the mDoSomething handler within the object referred to by 
someObjectReference, and will pass someOptionalParameters if you need 
to.  When you are finished using an object, you must explicitly get 
rid of the object by setting the object reference to some new value, 
for example:

    someObjectReference = VOID

Hope that helps.  The fact that behaviors can also have a "new" 
handler, and the explanation of the affect of ancestors is not 
important to the basic understanding of the difference between 
behaviors and parent scripts.

Basic difference: Behaviors are intended to be attached to sprites - 
beginsprite and endsprite handlers called automatically, and you can 
use GPDL.  Parent scripts only create objects when you as the 
programmer explicitly call the new handler, objects "live" until you 
kill them by setting the object reference (and any copies of the 
object reference) to VOID (or 0, or anything else).

Irv

At 10:53 AM -0500 12/3/01, Genevieve Young wrote:
>Thanks to Kerry, James  and Luke for taking the time and trouble to reply.
>
>
>Let me try to understand what you are all trying to say.
>
>a. When I use on new() me,none of the properties set in the 
>ongetPropertyDescriptionList are available,  so I can't use the on 
>GPDL?
>
>b.Why does Kerry write then that both will execute if you have both?
>In ancestor scripts it may or may not execute. Yet James writes
>that you need an explicit Lingo call to create a new instance of a 
>parent script.
>


-- 

Lingo / Director / Shockwave development for all occasions. 
          
   (Home-made Lingo cooked up fresh every day just for you.)

[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/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