At 9:05 PM +0100 12/15/00, Clars wrote:
>Actually, I think it's a good question - I'll try to shed some light.
>
>"me" resides at the heart of the difference between a simple sprite
>script and a true behavior. If your behavior handlers end with "me",
>they have two good things going for them:
>
>1). when a behavior initiates, an "instance" or copy of your script is
>created in RAM. If your behavior is attached to ten sprites, then ten
>SEPARATE copies (instances) of the script are created.
>That's good, because it allows all ten copies (instances) to have their
>own property values and react independently of each other, even though
>you've only written one script.
>
>2). All handlers in your sprite script, which has now become a behavior,
>have access to the property variables declared in the top of the
>behavior. I think of them as a kind af variable which are a stage
>between global and local - locals die with the handler, and globals
>are...global. Property variables are shared by all handlers in the
>behavior.
>
>So - to put it short, "me" is a pointer to the adress in RAM where this
>particular instance (copy) of your script resides.
>

Good explanation, but I'll add one comment.  Only one copy of the 
script lives in memory.  When you use multiple "instances" of a 
behavior  (e.g., use the same behavior on more than one sprites), 
Director allocates memory for a copy of the property variables in the 
script.  "me" is actually the address of the property variables for 
the current instance.  Because of this, using behaviors (or parent 
scripts) can be very memory efficient.  When the code of the behavior 
runs, it needs to know where its current property variables are - and 
the value of "me" tells it where to find them.

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