2 Replies Latest reply on May 21, 2008 1:17 PM by Mr.Wallace

    INPUT TEXT

    Mr.Wallace Level 1
      Hey all,

      I've been searching for similar entries/posts so that I'm not repeating anything, but so far, no luck.

      I was wondering...

      I've created a game which requires a user to input text into an input text box (I know, original stuff, LOL) and then press a SUBMIT button. When input text is correct, it goes to the necessary frame and everything is fine and dandy.

      BUT...

      I would also like the button to play a sound (eg. a BUZZER sound) if the input text is incorrect. I have tried several different things so far with no luck.

      So far my code looks like this (excluding the playing of a soundof course):

      on (release) {
      submit.onRelease = function () {
      if (answer.text == "right_answer") { gotoAndPlay("Right",1); }
      }
      }

      This code works GREAT so far but I just need to add in the sound playing part if the answer is wrong.

      Any ideas? Would appreciate the feedback greatly!

      THANKS!

      Mr. Wallace
        • 1. Re: INPUT TEXT
          robdillon Most Valuable Participant
          If you have a button instance on the stage with an instance name of submit then you could write this code to a frame actions space and not use the on(release) part. If you want to continue to use the on(release) event attached directly to the button, then you don't need to use submit.onRelease.... You only need to use one or the other.

          In any case, you have most of the code set up. You have a test for the contents of the textfield named answer. So you can just add an else condition to play the sound.

          1. Import a sound file into your movie's library. Open the Linkage window and check the Export for Actionscript. Give the sound an Identifier name of "buzzer".
          2. In a new layer in the movie, open the Actions window for the first frame of that layer.
          3. Create a sound object and attach that sound to the object.
          4. In your onRelease function have the sound play if the answer is incorrect.

          See the code below:
          • 2. Re: INPUT TEXT
            Mr.Wallace Level 1
            ROOOOOOOOB!!!

            That was SWEET!

            Thank you soooooooo much man I REALLY appreciate the help! It worked perfectly!!!

            Thanks again,

            Mr. Wallace