Hi There,

I'm not a real programmer, so forgive me if this is a stupid question.
I'm trying to create a child behavior that attaches itself to a sprite
and then de-attaches itself once it's done its job (over a few seconds).

This is what I did. I made a parent script of the behavior and called a
'new' instance of it in each sprite I wanted it to act on.

In its 'on new' handler, the new behavior takes the SpriteNum of the
calling sprite and adds itself to the sprite's scriptInstanceList. It
does via the line

'add Sprite(pThisSpriteNum).scriptInstanceList, me'.

That works to add the child to this list, but I can't get it back off so
easily. The scriptInstanceList of the calling sprite will contain an
item referring to itself and not the child.   I cannot make comparisons
or use deleteOne (etc.) using me.

I set a property in the calling sprite (ex. property pMyBehavior) and
then used it in this child code,

if **condition**  then
    repeat with n=1 to Sprite(pThisSpriteNum).scriptInstanceList.count
      if Sprite(pThisSpriteNum).scriptInstanceList[n].pMyBehavior = me
then
        Sprite(pThisSpriteNum).scriptInstanceList.deleteAt(n)
      end if
    end repeat
end if

but this will error when there are other behaviors attached to the list
that do not have such a property.

Is there any way that I can access my child object on the list after
I've added it there? 


Thanks for any help!






[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!]

Reply via email to