I don't think that having objects deleting themselves from their own
scriptinstancelist is good, I seem to recall that although the actorlist is
tolerant of this (ie. adjusts for deletions of objects in the list during
stepframe processing), the scriptinstancelist is not.

What I do is have handlers like so on all my behaviors:

on mDestroy me
  psymState = #dead
  sysAddToGarbage(me)
end

on mKill me
  sprite(spriteNum).scriptInstanceList.deleteOne (me)
end

When I want to get rid of a behavior I call "mDestroy" which calls a movie
handler accessor to my garbage collection object.  The garbage collection
object is in the actorlist and simply cycles through it's list of objects to
be deleted on each stepframe and calls "mKill" on them which actually
deletes the object (each object can have it's own custom mkill routine).
The psymState flag I use to flag the object as being dead so I can short
circuit it's handlers if I need to until it's actually deleted (a "state
engine" approach).

The important part of all this is that I don't think it's good karma to
delete objects from the scriptinstancelist during an event that was
generated from director cycling through that list (ie. prepareframe,
exitframe, enterframe, endsprite, beginsprite), otherwise director gets
confused and some objects in the list may not get their sprite events.

Steph

> -----Original Message-----
> From: Karina Steffens [mailto:[EMAIL PROTECTED]] 
> Sent: Thursday, February 22, 2001 10:09 AM
> To: Lingo-L (E-mail)
> Subject: <lingo-l> scriptInstanceList
> 
> 
> Hi everyone,
> 
> I've been just asked to debug an older project, that seems to 
> slow down the system more and more as it runs. And I'm 
> supposed to debug it NOW, in the next 10-20 minutes. (Ok, not 
> anymore - I've just been told the installation will be 
> postponed in any case, since we still need to test, but I 
> still need to get it ready for
> testing)
> 
> I've looked through it, and all the objects are being cleaned 
> up nicely through my cleanup routine. I optimized where I 
> could (cleaning up my cleanup routine, deleting lists in 
> object properties, that kind of thing). The one thing that is 
> bothering me is that I have a sprite behavior (attached to 
> multiple sprites) removing its own instance. The script is:
> 
> on deactivate me
>    me.cleanup()
>    mySprite.scriptInstanceList.deleteOne (me)
> end
> 
> on cleanup me
>    psTarget = Void
>    poGroundContol = 0
> end
> 
> (--poGroundControl is an object and psTarget is usually a 
> sprite but can in some cases become a list. The cleanup 
> method is also called from the endSprite event)
> 
> 
> Is that Kosher? Can a sprite's instance remove itself from 
> the sprite, or does it have to be done from outside?
> 
> Is there anything else that might be causing the trouble?
> 
> No timeOut or imaging objects, btw - it's an old project, D7 (windows)
> 
> TIA,
> 
> Karina
> 
> 
> 
> 
> 
> 
> 
> 
> 
> [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!]
> 

[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