Message timing problem
Graham Samuel
graham.samuel at wanadoo.fr
Fri May 14 08:32:03 EDT 2004
On Thu, 13 May 2004 11:38:06 -0600, Dar Scott <dsc at swcp.com> wrote (and
thanks for your input):
>On Thursday, May 13, 2004, at 10:45 AM, Graham Samuel wrote:
>
> > I dimly see that I may somehow have activated more than one instance
> > of my showNextFrame handler in some strange way
[...]
>This is usually the problem.
>
>One brute force method is to see if there is the same message in
>pendingMessages() before the send. Sarah likes this one.
I found this awkward because I have a number of objects each using a
handler with the same name: so I opted for a straightforward test to see if
the long seconds on this iteration is at least more advanced than my
animation frame interval. Seems to work. This says to me that there is only
one actual instance of the code and its globals, but I am about to read
your tutorial and will then understand more.
>Another is to use a script local variable for the message id. I use
>empty to mean none. Thus, if it is not empty, then there is a message
>pending.
Frankly I don't understand this yet (have never used a message ID) - needs
further study.
>However, it might be good to look at why this is happening. It might
>be that you are not reliably shutting down the mechanism.
Yes, the problem is (I think) that my shutting down mechanism involves
setting a global which is tested by the animation handler. Somehow this
setting only happens after a lot of animation frame messages have been
accumulated, and thus when I restart the handler I get an increased
population of messages, at least for a time - this also needs further
study. I have a nice demonstration that simply restarting the animation
several times makes it go faster and faster - this is undoubtedly the
'multiple instance' case; but in my own app as usual things are bit more
complicated to trace out.
>If you have a little time, you might want to go through the primer on
>"message mechanics" at my site:
>
> http://www.swcp.com/dsc/revstacks.html
Am about to - thanks Dar for this.
I now also have another anomaly in that an animation with a frame interval
of exactly 50 ms can stop by itself for no apparent reason, the 'stop' flag
not having been set. It's as if the pendingMessages queue had cleared
itself. It is doubtless caused by another of my errors but it is curious -
if I switch the frame interval to 55 for example, away it goes. Hmmph. The
whole thing is a lot more fraught than I expected.
Still working on it!
Graham
---------------------------------------------------
Graham Samuel / The Living Fossil Co. / UK & France
More information about the use-livecode
mailing list