9 Replies Latest reply on Mar 29, 2007 4:33 AM by Lukewig

    Placing a timeout

    brockus
      I would like to have the playhead hold on a frame for x amount of seconds and then jump to a marker. I think I need to use the timeout function but don't understand where I need to put it and what it should read. Can someone please help?

      Thanks in advance...
        • 1. Re: Placing a timeout
          Level 7
          Here is a great writeup of how the timeout objects work:

          http://director-online.com/dougwiki/index.php/TimeOut
          • 2. Re: Placing a timeout
            brockus Level 1
            I have come across this article and unfortunately I need something written with an unexperienced coder in mind. Kind of like - put this in your movie script and put this on your frame script.
            • 3. Re: Placing a timeout
              duckets Level 1
              You could use a timeout for this purpose, but it can be achieved more simply.

              If you don't need any interactivity during that frame, you can just double click the 'tempo' cell (in the score) on the frame you want to hold. Select 'wait' and move the slider to the appropriate number of seconds, and click ok. Then, double click the frame script cell (in the score) on the same frame, which will open a script window, and type:

              on exitframe
              go to frame "myMarkerName"
              end

              Alternatively (instead of typing that script) you could use the 'jump to marker' behaviour bundled with director, in the behaviour library.


              - Ben
              • 4. Re: Placing a timeout
                brockus Level 1
                I have tried this as well, but I have a film loop running on the frame that is holding. If I use the built in "wait" is freezes this film loop.
                • 5. Re: Placing a timeout
                  duckets Level 1
                  In that case, you'll need some slightly more complex code in the exitframe handler. You still won't need a timeout object though. Try this:

                  Set your tempo back to the tempo that you want your film loop to run.

                  Change the frame script on that frame to read:


                  -----------------------------------------------
                  property startMS

                  on beginsprite me
                  startMS = the milliseconds
                  end

                  on exitframe me
                  if the milliseconds > startMS + (8*1000) then
                  go to frame "myMarkerName"
                  else
                  go to the frame
                  end if
                  end
                  --------------------------------------------

                  (the above example waits for 8 seconds - change the '8' to whatever you want, and change "myMarkerName" to whatever your marker is called.

                  - Ben
                  • 6. Re: Placing a timeout
                    brockus Level 1
                    duckets you are the man (or woman)! Thank you! What is the purpose of this confusing timeOut function if it really isn't needed?
                    • 7. Re: Placing a timeout
                      duckets Level 1
                      Timeouts are for setting up delayed events, most commonly events that need to be repeated at regular intervals, regardless of what other code is being executed. They are useful in certain situations, and it would have been possibly to solve your problem using one, but really it would have been more complex than necessary!

                      read more here:
                      http://director-online.com/buildArticle.php?id=992

                      - Ben (man!)

                      • 8. Re: Placing a timeout
                        wuschdwegga
                        Hi,
                        i took your code and it works well. But I have a further problem. My Timeout should only start if 30 sec nothing happens (no mouseclick, no keyboard). Like it is now it starts also when i click on my screen.

                        I know that it have something to do with a lastevent. But i really don't know how to put it into my code.

                        Can anyone please help me?

                        Thx and greets
                        wuschdwegga
                        • 9. Re: Placing a timeout
                          Lukewig
                          Hi,

                          LastEvent measures the time since the last keyPress, mouseclick or mouse movement. You would use it like this (in a frame script in the frame you are waiting on):

                          on exitframe me
                          -- check if nothing has happened for 10 seconds
                          if _player.lastEvent > 600 then -- 60 ticks is approx 1 second
                          go to "myMarkerName"
                          else
                          go to the frame
                          end if
                          end


                          If you just want to wait for no clicks or keyPresses, then you can do this:

                          on exitframe me
                          lastClickOrKey = min(_player.lastClick, _player.lastKey)

                          if lastClickOrKey > 600 then -- 60 ticks is approx 1 second
                          go to "myMarkerName"
                          else
                          go to the frame
                          end if
                          end

                          Otherwise you could use the timeoutScript (not to be confused with timeout objects). The timeoutScript has been around since Director 1 or something but seems to have fallen off the documentation in recent versions. Basically, it works like this:

                          -- this is a movieScript

                          on StartCheckingForTimeout
                          the timeoutScript = "HandleTimeout"
                          the timeoutLength = 600
                          end

                          on HandleTimeout
                          the timeoutScript = "" -- delete the timeout script if we dont need it
                          go to "myMarkerName"
                          end

                          When you want to start waiting for a timeout, you would call the 'StartCheckingForTimeout()' function. If you stop needing it for whatever reason, you simply set the timeoutScript back to an empty string.

                          -- Luke