At 9:10 -0500 2001_12_04, Genevieve Young wrote:
In Director terminology you speak of "Parent scripts", "child
objects" and "handlers".
In the same things are known in generic OOP parlance as "Classes",
"Objects" and "methods".
Director has three types of scripts:
1) movie
2) behavior / score
3) parent
basically they're all just "scripts" and as such, all of them can be
instantiated as "objects".
They differ like so:
1) "movie" scripts is the only type that receives "movie events"
2) "score" scripts is the only type that can be manually and attached
to sprites in the score.
Parent scripts is mainly defined by what they do *not* do, ie:
doesn't receive movie events, and can't be manually attached to the
score.
Generally you don't treat movie-scripts as "classes", and don't
create "object-instances" from them, but you could do it, if you so
desired.
Generally you don't create instances from behaviors by use of
explicit lingo, but rather let the score do it, when it encounters an
attached behavior in the score, during runtime. But you could if you
wanted to.
Director can't automatically create instances from parent-scripts,
because they are not score-attachable, so you have to it by lingo.
Anyway: When an instance has been created from a "class", it is an
"instance", regardless of its origin, ie:
"Instances are instances are instances".
When Director instantiates a behavior from the score, it places a
reference to the instance in the script's "scriptInstanceList", and
removes the scriptInstanceList itself, when the sprite "ends".
Director also send certain messages, so-called "score-events", to
instances in scriptInstanceLists, such as "new" and "beginSprite" to
automatically created instances, and "prepareFrame", "enterFrame",
"exitFrame", and "endSprite" to any object in the scriptInstanceList.
Through Lingo you can put object-references into scriptInstanceLists,
regardless of scriptType or method-of-creation of these objects, and
they will receive the expected "score-events".
Technically speaking (very):
Instances are *not* created by the "new" method in the script-text of a script.
The instance is created by an implicit "new" method in the
"script-object", which can be considered an implicit sub-class of the
"script" as defined by the script-text.
After the instance has been created, the "new" message is forwarded
to the newly created instance, *if* there is one. This is how the
"me" reference magically appears the change during the "new" message,
and that is why a "script" needs not contain an explicitly defined
"new" handler in the script-text, whether it is a "parent",
"behavior", or even "movie" -script, for it to be "instantiable".
Since D8, Lingo has had the keyword "rawNew", which is an implicit
method in the "script", that allows you to create instances without
any message being sent to the newly created object.
Roughly you can translate:
o = script("myClass").new()
into:
o = script("myClass").rawNew()
call #new, [o]
And the process that happens when Director instantiates a behavior, roughly:
<s = sprite(x)>
sil = s.scriptInstanceList
repeat with c in s.scriptList
o = c.rawNew()
o.spriteNum = x
sil.append(o)
call #new, [o]
end repeat
<call #mInitiateProperties, sil>
call #beginSprite, sil
So accordingly:
>i. a behavior is a class?
Yes
>
>ii. classes are therefore not variables?
The closest match is to say that; a class is roughly the
"script-object-part" of a script-member, and a variable can hold a
reference to a class.
>iii.we can define our own handlers in parent scripts?
As you can in any type of script.
>iv. so a parent script is a class?
Yes, as is any any type of script.
>v. and therefore a behavior is somewhat similar to a parent script?
It is a parent-script that is allowed to be manually attached to the score.
>vi. and so behaviors can be used to create objects?
Yes, as you can with any type of script.
But generally "the score" creates instances of behaviors, and you do
it by Lingo with parent-scripts.
>Is this correct?
Yes.
Hope some of that helped, Jakob.
[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!]