I remember one big project I was working on where this became a real
problem. My solution was to work around the problem by creating a
"FrameManager". The basic idea is this.
The FrameManager is a global object that inserted itself into the
actorList. It is the only thing that is ever in the actorList. If
you want an object to receive the equivalent of stepFrame messages,
then you call a method in the FrameManager to "register for frame
events" passing "me" as a parameter (your own object reference). The
FrameManager maintains a list of objects that want frame event
messages. So, in it's "on stepFrame" method, it calls "mFrameEvent"
for every object in it's list. Therefore, if you have an object that
has registered with the FrameManager, you get called back every frame
in your mFrameEvent method.
The FrameManager also had a "unregister frame events" handler. The
code here is the key. Rather than immediately deleting the object
reference from it's list, it built a new list of objects that wanted
to be deleted. Then it only deleted objects from it's list at the
beginning of it's stepFrame handler.
Works great. Some day when I have time, the full description with
code will be in my online book at:
http://www.furrypants.com/loope
Irv
At 3:30 PM +0200 4/26/01, Jakob Hede Madsen wrote:
>At 13:39 +0000 01_04_26, Christian Wach wrote:
>>Jakob Hede Madsen wrote:
>>
>>> You may be aware that when an object removes itself from the
>>> actorlist from within its stepFrame handler, then the next object in
>>> the actorList misses an event.
>>
>>yeesh!
>>
>>never heard of (or observed) this before...
>>
>>is this documented anywhere?
>
>At least it has been discussed on Director lists before, although
>it's not one of the subjects that iterates every other week.
>There is nothing spooky about it, it will happen anytime you delete
>items from a linear list during forward traversal, and the general
>trick is to traverse backwards.
>
--
Lingo / Director / Shockwave development for all occasions.
(Home-made Lingo cooked up fresh every day just for you.)
[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!]