Skip navigation
Currently Being Moderated

Problem with exitFrame/startTimer

Apr 21, 2012 1:44 AM

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

 
Replies
  • Currently Being Moderated
    Apr 21, 2012 3:55 AM   in reply to Jhon Carlo

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 21, 2012 8:02 AM   in reply to Jhon Carlo

    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

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 21, 2012 10:35 AM   in reply to Jhon Carlo

    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

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 22, 2012 5:59 AM   in reply to Jhon Carlo

    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.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points