Michael von Aichberger <[EMAIL PROTECTED]> wrote:
> on stepframe me
>   go to the frame
> end
> 
> This doesn't stop the playback head - why?

Hi Michael,

The stepFrame handler is triggered when you go to a new frame.  If you could
go to a different frame from inside the stepFrame handler, you would get
into an infinite loop.  To prevent this, go commands are ignored inside a
stepFrame handler.

> I want to achieve... a program that synchronizes "slides" to sounds or
> video....I want to store the time cues in a list, mark the cue points in
> the score with markers and check on every stepframe, if there is a marker
> and if so, search a list for the sync time and hold the playback head in
> the frame until that sync time is passed.

Since you want to avoid using a frame script, you could create a global
instance of a parent script that will react to #exitFrame events rather than
#stepFrame events.  To do this, you can use a timeOutObject to divert movie
events to the script instance, as shown in the Parent Script below.

To test the script:
1. Create a new movie
2. Record a 10 second sound  and place it in sound channel 1
   stretching over frames 1-84
3. Place a shape sprite in sprite channel 1, over 28 frames
4. Copy the shape sprite and place it in frames 29-56
5. Change its color to red
6. Place a marker in frame 28, just before the change of color
7. Repeat steps 4-6 for frames 57-84, using green and placing
   the marker in frame 56.  Give this marker a different name.
8. Create the following movie script:

   global gCueTimes


   on startMovie()
     gCueTimes = script("Wait for cue time at marker").new()
   end startMovie


   on stopMovie()
     gCueTimes = VOID
   end stopMovie

Run your movie.  Is that the effect you are looking for?

To customize the delays, simply create a list of markers and cue times in
the startMovie handler, and pass that list as a parameter.  For example:

   on startMovie()
     tList = [:]
     tList["New Marker"]   = 2500
     tList["Newer Marker"] = 7000
     gCueTimes = script("Wait for cue time at marker").new(tList)
   end startMovie

Note: the parent script below uses a case-sensitive technique for matching
cue times to marker names, so you must ensure that your list uses the same
case for the marker names as the score does.

Cheers,

James


----------------------------------------------------------------------------


-- PARENT SCRIPT "Wait for cue time at marker"

property pTimeOut
property plCueTimes
property pNextTime



on new(me, aCueTimesList)
  pTimeOut = timeOut("exitFrame").new(0, #dummyHandler, me)
  -- The timeOut object will divert #exitFrame, #stopMovie and other
  -- movie events to this instance
  
  if ilk(aCueTimesList, #propList) then
    plCueTimes = aCueTimesList
    
  else -- Define the cue times automatically for testing purposes
    plCueTimes = [:]
    tCueDelay  = 2000 / the frameTempo
    tMarkers   = the markerList
    tCount     = tMarkers.count
    repeat with i = 1 to tCount
      tFrame = tMarkers.getPropAt(i)
      plCueTimes[tMarkers[i]] = tFrame * tCueDelay
    end repeat
  end if
  
  return me
end new



on stopMovie() -------------------------------------------------------
  -- Movie event sent by the timeOut object
  -- ACTION: Clears up any mutual references to avoid a memory leak
  --------------------------------------------------------------------
  
  pTimeOut.target = VOID
  pTimeOut.forget()
  pTimeOut        = VOID
end stopMovie



on exitframe() -------------------------------------------------------
  -- Movie event sent by the timeOut object
  -- ACTION: Waits at each marker until the appropriate cue time has
  --         passed.
  --------------------------------------------------------------------
  
  if pNextTime then
    -- Wait at this marker until the cue time is passed
    if sound(1).currentTime < pNextTime then
      go to the frame
      
    else
      -- Move forward until the playback head reaches the next marker
      pNextTime = 0
    end if
    
  else
    -- The playback head was moving forward in the last frame
    tLabel = the frameLabel
    if tLabel <> 0 then
      -- We've arrived at a new marker
      pNextTime = plCueTimes[tLabel] -- case sensitive

      if sound(1).currentTime < pNextTime then
        -- Wait for the cue time
        go to the frame

      else
        -- The cue time is already passed
        pNextTime = 0
      end if
    end if  
  end if
end exitframe

[To remove yourself from this list, or to change to digest mode, go to 
http://www.penworks.com/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