Rob Romanek <[EMAIL PROTECTED]> wrote: >The code says to make a call use > > call (#handlerName, sprites(#theName)) > > since sprites handler returns a list of sprites in the form of [(sprite > 1), (sprite 2), etc] then in the behaviours attached to the sprites the > me in the handler is a reference to the sprite and not the actual > behaviour instance. As a result any code that uses the me. syntax will > end up not referencing the instance of the behaviour but rather the > sprite.
Hi Rob, Many thanks for picking up on this. In the situation you describe, you can use a more sophisticated call: tSpriteList = Sprites(#spriteName) tCount = tSpriteList.count repeat with i = 1 to tCount tBehaviors = tSpriteList[i].scriptInstanceList call(#handlerName, tBehaviors) end repeat An alternative would be to add a method to the Sprite Names behavior: on CallSprite(aSpriteName, aHandler, aParameter) --------------------- -- INPUT: <aSpriteName> should be a string or (preferably) a -- symbol -- <aHandler> should be a symbol handler name -- <aParameter> can be any Lingo value, including VOID. To -- make a call requiring multiple parameters, you can use a -- list or property list. -- ACTION: activates the handler <aHandler> in the behaviors in the -- scriptInstanceList of each of the sprites in the list of -- sprites named <aSpriteName>. The value of "me" passed -- to each behavior instance will be a pointer to the -- instance itself, not a pointer to the sprite the behavior -- is attached to. -------------------------------------------------------------------- if not symbolP(aHandler) then exit end if case ilk(aSpriteName) of #string, #symbol: tSpriteList = script("Sprite Names").namedSpriteList tNameSakes = tSpriteList[aSpriteName] tCount = tNameSakes.count repeat with i = 1 to tCount tBehaviors = tNameSakes[i].scriptInstanceList call(aHandler, tBehaviors, aParameter) end repeat otherwise mSpriteNames_TreatError(#invalidName) end case end CallSprite Cheers, James [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!]