3 Replies Latest reply on Aug 27, 2007 3:20 PM by kglad

    Only play once per loop

    shurleynova
      I have a keyClass handler that plays a sound based on variable in each loop of the script. The problem is I only want the key to work one time each loop. Any ideas. I have attached the code for reference.
        • 1. Re: Only play once per loop
          kglad Adobe Community Professional & MVP
          does snds change value on each loop? if so, you can use it and an if-statement. if not, you'll need some variable that does change value on each loop or you'll need to start another loop (in your listener) that checks on the original loop.
          • 2. Re: Only play once per loop
            shurleynova Level 1
            snds does change value each loop it flip-flops between one of two sound files.
            If someone presses the key during a loop that they are supposed to respond they get a happy beep, if they press the space bar during a loop they are not supposed to respond it plays a buzz sound.

            So what you are saying is if I create an if statment (inside the keyListener) that says if the key has been pressed alreaady this loop than it should not play the sound. it should work?

            Makes sense to me, now lets see if I can make it work.
            • 3. Re: Only play once per loop
              kglad Adobe Community Professional & MVP
              alternating between two values won't work because someone make press once during a loop and then not press again next loop but then press the loop afterwards. so, snds will have changed (twice) but will back to its original value. you'll need to use another variable. a loop counter would be sufficient.