switching between movies

Cubist at aol.com Cubist at aol.com
Tue Aug 24 02:36:30 CDT 2004


sez userev at canelasoftware.com:
>On Aug 23, 2004, at 12:28 AM, Jason Tangen wrote:
>
>> I have two movies (both 640x480, 240 frames, ~2MB each).  I want to 
>> allow the user to click a button to switch back and forth between the
>> two without delay.  Right now - I'm using the following strategy:
>>
>> on keydown key
>>   if key = space then
>>     put the currentTime of player "A" into Atime
>>     set lockscreen to true
>>     hide player "A"
>>     set the currentTime of player "B" to Atime
>>     show player "B"
>>     start player "B"
>>     set lockscreen to false
>>   else pass keyDown
>> end keydown
>>
>> ...but this results in a rather noticeable delay between the clips.
>
>Hi Jason,
>
>I modified your program slightly.  The main thing I noticed was to take
>out the lock screen.  This made things pretty snappy.  The faster the 
>computer, the faster the transition.  I put this code at the card level.
>
>on keydown thekey
>   put thekey
>   if thekey = "1" then
>     stop player "B"
>     put the currentTime of player "B" into Atime
>     hide player "B"
>     set the currentTime of player "A" to Atime
>     show player "A"
>     start player "A"
>   end if
>
>   if thekey = "2" then
>     stop player "A"
>     put the currentTime of player "A" into Atime
>     hide player "A"
>     set the currentTime of player "B" to Atime
>     show player "B"
>     start player "B"
>   end if
>   pass keyDown
>end keydown
   Speaking as an amateur with a fetish for minimizing the number of lines of 
code, I'd be interested to see if the following modification of your handler 
is any better or worse than your code...

on keydown thekey
  put thekey
  switch theKey
    case 1
      put "B" into OldPlay
      put "lay
  put the currentTime of player OldPlay into Atime
  hide player OldPlay
  set the currentTime of player NuPlay to Atime
  show player NuPlay
  start player NuPlay

  pass keyDown
end keydown

   ...inquiring minds want to know!


More information about the use-livecode mailing list