problem with callbacks

Jan Schenkel janschenkel at
Wed Oct 8 03:46:00 EDT 2003

--- Toma Tasovac <ttasovac at> wrote:
> (sorry if this is a double post, but the list seems
> to have been dead 
> all day long)
> Thanks to Ken and Jan for responding.  For some
> reason, I couldn't get 
> to prevent the callbacks from showing with a simple
> if clause... I 
> started now with a different approach, which works
> with preventing the 
> callbacks from showing if they've already been
> showed, but lands me in 
> trouble with onCurrentTimeChanged
> Here's what I've done.  On openStack, I create a
> global myCallbacks -- 
> so that at any time I can have a list of all
> callbacks available.  My 
> callback messages (sentnece 1, sentence 2, sentence
> 3) do the following:
> on sentence x
>    lock screen
>    set the textColor of item x-1 of fld "Field 1" to
> black
>    set the textColor of item x of fld "Field 1" to
> blue
>    put x into lastPlayed
>    unlock screen
>   end sentence
> Now, since I want to avoid repeated executions when
> the user stopps the 
> movie, I have:
> on playPaused
>    put the callbacks of player "Player 1" into
> tempCallbacks
>    delete line 1 to lastPlayed - 1 of tempCallbacks
>    set the callbacks of player "Player 1" to
> tempCallbacks
> end playPaused
> So far so good.  When the user stops the movie and
> then continues 
> playing -- previous callbacks are not sent. 
> Beautiful.
> But then, I want to deal with onCurrentTimeChanged,
> that is if the user 
> scrolls back to the beginning of the movie.  I
> thought this would be 
> simple enough:
> on currentTimeChanged
>    set the callbacks of player "Player 1" to
> myCallbacks
> end currentTimeChanged
> But this DOESN'T work because (as Message Watcher
> will tell us) when 
> the user moves to the beginning of the movie,
> currentTimeChanged is 
> sent, but when the user releases the scroller,
> another "playPaused" is 
> sent, which means I'm stuck again with a truncated
> version of callbacks 
> (from on playPaused handler) and the not the full
> version that I 
> expected from my global variable.
> What's the best thing to do now?
> Many thanks in advance.
> T.

Hi Toma,

Glad to hear you're getting closer to a complete
solution. What I'd do in this case, is use one more
script local sJustChangedTheTime, set it to true in
your currentTimeChanged handler, and reset it to false
from within your playPaused handler but not execute
the rest of that handler's code.

local sJustChangedTheTime

on currentTimeChanged
  put true into sJustChangedTheTime
  -- ...
end currentTimeChanged

on playPaused
  if sJustChangedTheTime then
    put false into sJustChangedTheTime
    -- ...
  end if
end playPaused

You may have to tweak the mechanism a bit, but this
ought to bring you closer to a solution.

Jan Schenkel.

"As we grow older, we grow both wiser and more foolish at the same time."  (La Rochefoucauld)

Do you Yahoo!?
The New Yahoo! Shopping - with improved product search

More information about the Use-livecode mailing list