Hi Pedro

I'll do my best to answer your question.

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:

set the fgcolor of sprite me = 156

it will generate an error.  In this case director is expecting an integer
(the number of the sprite) not the memory address of the behaviour attached
to the sprite.  Now you can use the term me in conjunction with the
spriteNum property to get the integer value:

set the fgcolor of sprite(me.spriteNum) = 156 (in D7 or above).  I'm tired,
but I don't recall a fgcolor property of a  sprite, I'll assume you are
referring to the foreColor of the sprite.  Thus what you are attempting to
do is:

set the foreColor of sprite(me.spriteNum) = 156

or perhaps in older lingo (pre D7) it might correspond to something like
set the foreColor of sprite(the spriteNum of me) = 156  (don't hold me to
this though, perhaps someone could step in and fix that one up).

Normally, one would declare the spriteNum property as a property to the
behaviour and thus make it accessible without the need to include the me
reference.

ie.

property spriteNum

on mouseUp me
        set the foreColor of sprite(spriteNum) = 156
end mouseUp

And if you were to repeatedly do operations on a given sprite, ie. rollover,
down and other events, then one would go a step further and declare the
entire sprite as a single property and access it as such.

ie.

property pSprite

on beginSprite me
        pSprite = sprite(me.spriteNum)
end beginSprite

on mouseUp me
        set the foreColor of pSprite = 156
end mouseUp

or

on mouseUp me
        pSprite.foreColor = 156
end mouseUp

The reason for using a single sprite reference such as pSprite is that when
repeatedly performing such an operation, there is a performance gain by
accessing a single reference vs recreating the full reference each time.
That might not factor into a simple movie, but it can be a good habit to get
in to if you work on more complex projects.

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. thus
again alluding to a good reason for holding the entire reference to the
sprite in a property vs depending on the me parameter as a guide.

The "me" parameter is passed internally when you would click on sprite. The
behaviour ("me") recieves the mouseEvent and directs it to the appropriate
handler within itself, in this case a mouseUp and it passes a reference to
itself (the memory address) as the first parameter.

I don't know if I helped or just muddied the waters even more for you.

Sincerely

Mark

--------------------------------------------
Mark R. Jonkman
Mark R. Jonkman Consulting
ADDRESS: 20 Windermere Crt., Guelph, ON, CANADA N1E 3L4
PHONE: 519-837-8509
EMAIL: [EMAIL PROTECTED]
--------------------------------------------


[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