At 5:10 AM -0500 10/30/00, Mark R. Jonkman wrote:
>
>
>The term "me" is a reference to the instance of a particular behaviour or
>object instance (although it can also be an integer if using a sendSprite(x,
>#somehandler)). Because "me" is most frequently a reference to an instance
>of a script it has no "relevance" to the actual sprite persae. In other
>words, "me" refers to the address in memory of the instantiated script and
>does not directly refer to the sprite to which the behaviour is attached.
>thus when you attempt to do:
>

Here is a way to think about this.  Whenever you have a behavior (or 
parent script) in your code, that code is "compiled" and is available 
in memory.  When you attach the behavior to a sprite, Director 
creates a copy of the all the properties declared in the behavior 
script.  The block of memory used to represent these properties is 
called the "instance" of that behavior.  And the variable "me" is 
really the memory address of that "instance".  So, if you were to 
attached the same behavior to 2 different sprites, (let's just say 
sprite 1 and sprite 2), then a block of memory is allocated for the 
properties of the behavior attached to sprite 1 - and another block 
of memory is allocated for the properties of the behavior attached to 
sprite 2.  At runtime, the variable "me" will be different when 
running the behavior on sprite 1 vs running the same behavior on 
sprite 2, because the address of the property variables attached to 
those sprites is different.

<snip>

>Now I alluded to the fact that me might be able to take an integer value
>from time to time.  If you are calling the behaviour from another sprite for
>instance then you would use sendSprite(x,#someHandler) where x is the
>integer of the sprite being called.  Because the behaviour recieves x as a
>parameter in the recipient sprite, it places x in the first parameter
>location of the sprite, which in this case is the me reference. Thus
>internally the handler will function handle me as the integer value of the
>sprite and not the memory address of the instance of the behaviour.
>

I don't think this is exactly right.  My guess is that "sendSprite" 
actually does a translation for you.  For example, if you said:

   sendSprite(12, #someHandler)

Then when this executes, the code that implements "sendSprite" 
(within Director), gets "the scriptInstanceList" of the sprite (in 
this case 12), and then calls the somehandler of each instance. 
Something like this (pseudo-code of Director - written as Lingo):

   on sendSprite spriteNumber, handlerName, anyOtherParams ...
       theLocalScriptInstanceList = sprite(spriteNumber).scriptInstanceList
       call(handlerName, theLocalScriptInstanceList, anyOtherParams ...)
   end

The point that I'm trying to make is that when the handler of the 
behavior is called, the "me" parameter is always a memory address of 
the instance of the behavior - and never an integer.

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