8 Replies Latest reply on Apr 27, 2012 2:12 AM by Jhon Carlo

    Problem with exitFrame/startTimer

    Jhon Carlo Level 1

      Why the following script does not work?

       

      on exitFrame me

        if member("MyText").text = "x" then

          go to the frame

        end if ---(with else is the same)

        if member("MyText").text = "y" then

           startTimer

           if the timer < 5000 then

              go next

            end if

          end if

        end if

      end

       

      I have tried some variations on this approach but it does not work.

      Some help?
      Thanks

        • 1. Re: Problem with exitFrame/startTimer
          Sean_Wilson Adobe Community Professional

          You have one too many 'end if' statements in your code.

           

          It's difficult to know what is happening (you don't say), especially since you give no clues as to what the text of member "MyText" contains or, more generally, what you're trying to achieve. You're obviously wanting to pause on a particular frame until the text of a member is a certain character, but how do you initialise this text member and where is the code you posted attached? For example, if the code is in the frameScript channel and member("MyText") is anything other than "x" or "y" when it runs then the playhead will breeze past this frame and onto the next one.

          • 2. Re: Problem with exitFrame/startTimer
            Jhon Carlo Level 1

            Thank you Sean for you fast reply!

            Sorry, of course, I've write more "and if" in the previous post then in my original script.

            I'm trying to stop for a while on the frame (the previous script is in a "frame Script"). My text contain only a "X" or "Y" (but il can contain "foo" or whatever). I switch form X or Y from a button, but the condition (x and y) have non effect and I miss the: "go to the frame" on the "exitFrame".

            Can you give me any hint?

            Thank you.

            • 3. Re: Problem with exitFrame/startTimer
              Production Monkey Level 3

              This may be what you are trying to do:

               

              on exitFrame me

                if member("MyText").text = "y" then

                  startTimer

                  go next

                else

                  go the frame

                end if

              end exitFrame

               

               

              Another approach would be to use the exitframe handler for nothing but pausing on a frame and then take the action of going to the next frame in your button script.

               

              on mouseDown me

                  member("MyText").text = "y"

                  startTimer

                  go next

              end mouseDown

              • 4. Re: Problem with exitFrame/startTimer
                Jhon Carlo Level 1

                Thanks Production Monkey for the kind reply,
                but I need the condition: "Timer > ...." I tried your suggestions by making the following changes:

                exitFrame on me
                   if member ("Recording"). text = "stoRegistrando" then
                     startTimer
                     if the timer > 500000 then --- (I tried this with different values)
                       go next
                     end if
                   else
                     go the frame
                   end if
                end exitFrame

                But it does not work. When imposed "MyText" = "y", with the button, the movie go immediately to the next frame without aspect even a moment. I tried putting "startTimer" in the button, like you suggested, but it does not work. Why?
                Any advice?
                Thanks

                • 5. Re: Problem with exitFrame/startTimer
                  Production Monkey Level 3

                  I did not understand that you want to use the timer to delay the jump to the next frame. I would use a timeout object to create the delay

                   

                  Try this frame script. I assume you are using D10 or later.

                   

                   

                  property Paused  -- true/false flag indicating in paused state

                   

                  on beginSprite me

                    Paused = false

                  end

                   

                   

                  on exitFrame me

                    if member ("Recording"). text = "stoRegistrando" AND Not Paused then

                      tmp = timeout().new("paused_"&me, 3000,  #goNext, me) -- 3000 = 3 second delay

                      Paused = true

                    end if

                   

                    go the frame

                  end exitFrame

                   

                   

                  on goNext me, timeOb

                    timeOb.forget()

                    go next

                  end goNext

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

                   

                   

                  Or, like I mentioned above just pause on the frame and use a button script to go to the next marker.

                   

                  on mouseDown me

                    member ("Recording"). text = "stoRegistrando"

                    tmp = timeout().new("paused_"&me, 3000,  #goNext, me) -- 3000 = 3 second delay

                  end mouseDown

                   

                   

                  on goNext me, timeOb

                    timeOb.forget()

                    go next

                  end goNext

                  • 6. Re: Problem with exitFrame/startTimer
                    Jhon Carlo Level 1

                    Thanks again Production Monkey,


                    only the mouse
                    script works, but not always!!!

                    I think there is some problem in the context. I must stop to recording a sound file when it is finished "mix.stopSave ()". I do not want to do this to the user because if doesn't stop this could continue record and to fill the HD. So I want to determine, according to the length of the track, when the recording must stop. (sound(...).isBusy()) doesn't work.
                    As mentioned above only the mouse script works but not always.

                    I tried to understand the timeOut but I must say that the help of Director is not the most clear, there are no concrete examples. So

                    thanks you also for this, now I understand the TimeOut object.

                     

                    Any further suggestions?
                    Thank you very much.

                     


                    • 7. Re: Problem with exitFrame/startTimer
                      Production Monkey Level 3

                      You don't say what happens when the mouse script does not work.

                       

                      I'm also confused by what you are trying to accomplish. My best guess is that you are saving a sound file and you want the save to complete before moving to another frame.

                       

                      Timeout objects are great for monitoring/polling a condition because they will continue to call a handler at a regular interval until you forget them. The pseudo code for saving an audio file and then waiting for it to complete before moving to another frame would be:

                       

                      on mouseDown me

                        member ("Recording"). text = "stoRegistrando"

                        soundObjRef.save("C:\audio.wav")

                        tmp = timeout().new("paused_"&me, 500,  #isSaveDone, me) -- 500 = 0.5 second delay

                      end mouseDown

                       

                       

                      on isSaveDone me, timeOb

                        if soundObjRef.isSaving()then

                          put "Still saving sound file"

                        else

                          timeOb.forget()

                          put "Done saving sound file."

                          go next

                        end if

                      end isSaveDone

                       

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

                       

                      Note:  This code is untested and will need to be modify to work.

                      • 8. Re: Problem with exitFrame/startTimer
                        Jhon Carlo Level 1

                        I apologize for answering so late, but these days I could not work on your last help. I tried it today and it works great.
                        Thanks a lot for your help.