on 14/9/00 7:40 PM, James Newton at [EMAIL PROTECTED] wrote:
> Since the message arrives at the ancestor via the behavior instance, the
> <me> parameter refers to the behavior instance and not the ancestor.
...snip
> * a child instance can access its ancestor's handlers and properties
> as well as its own. While handlers in the ancestor script are
> executing, the <me> value is that of the child instance.
> * the ancestor instance has no knowledge of its children if it is
> called directly.
> * if a handler in an ancestor is triggered because no such handler
> appears in the child, then the ancestor handler can access properties
> and handlers in its child, so long as they are identified by "me."
> (e.g: me.spriteNum)
Hi James,
Its good to hear your accurate explanation - much better than my waffle.
You're right, the "me" in the handlers/methods of the ancestor that are
responding to messages sent to the sprite behaviour and passed up to it via
the ancestor relationship are actually referring to the sprite behaviour
instance (in contrast to the "me" in handlers responding to direct calls to
the ancestor, which refer to the instance of the ancestor script itself)...
thus its more precise to think of the behaviour as 'learning' (inheriting)
the methods of the ancestor, rather than the other way around (though the
fact that the ancestor has knowledge of its children when responding to
messages received via its children is often over looked).
Confusingly, the "me" also has a third incarnation - the sprite reference.
This is illustrated by this:
-------- Behaviour --------
property ancestor
global gParentScriptObj, gSpriteReference
on beginSprite me
gParentScriptObj = script("ParentScript").new()
gSpriteReference = sprite(me.spriteNum)
ancestor = gParentScriptObj
end
-------- Ancestor --------
on new me
return me
end
on mWhoIs me
put me
end
--------
then in the message window
sendAllSprites(#mWhoIs)
-- <offspring "SpriteBehaviour" 4 7689564>
call(#mWhoIS, gParentScriptObj)
-- <offspring "ParentScript" 4 768d0e8>
call(#mWhoIS, gSpriteReference)
-- (sprite 2)
So the "me" in the ancestor's methods refers to one of three things,
depending on whether it is being referred to in a method being evoked
directly or via the behaviour, and whether that message was generated by
"sendSprite" directed at the sprite reference, or a "CalL' to the sprite
reference (which probably shouldn't be valid syntactically anyway)
> Further considerations:
> me.getaProp(#propertyName) and me[#propertyName] can also be used.
> The effect is somewhat different: the first will access a property in
> the child instance, while the second will access a property in the
> ancestor. If both child and ancestor have properties with the same
> name, you can use this to distinguish between them. If a property with
> the given name does not exist, both these forms will return <Void>.
Thats interesting - so in effect, there is no "me" - its all contextual. How
very post-modern! I think I need to go and have some cafe lattes and read
some Habermas...
Luke
--
Luke Wigley
Multimedia Slave
Mecca Medialight Pty Ltd
Mecca Medialight: Medialight Sound Studio:
111 Moor Street 1 Bakehouse Lane
Fitzroy, Vic. 3065 North Fitzroy, Vic. 3068
Tel +613 9416 2033 Tel +613 9416 2033
Fax +613 9416 2055 Fax +613 9416 2055
www.medialight.com.au
__________________________________________________________________________
[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!]