3 Replies Latest reply on Jun 2, 2011 12:14 PM by Ned Murphy

    Trouble assigning more than one input term to input text box

    kirrwed Level 1

      Here is my code:

       

      stage.addEventListener(KeyboardEvent.KEY_UP, isWritingEvent);

       

      function isWritingEvent(e:KeyboardEvent):void {

          if(e.keyCode == 13){

               if (answer1_input.length > 0 && answer1_input.text == "blue") {

                     gotoAndPlay(1, "Right3");}

         {

          if (answer1_input.length > 0 && answer1_input.text == "green") {

                     gotoAndPlay(1, "Right3");

               } else {

                     gotoAndPlay(1, "Wrong3");

               }

          }

      }

      }

       

      This code corresponds to a quiz question where the correct answer is either blue or green. I get the #1009 error if I input "blue".  The answer "green" seems to work ok.  What's wrong with my code?  Is there a better way to make is so more than one answer works?  Something like "blue" or "green" or "otheranswer", etc.. ? 

        • 1. Re: Trouble assigning more than one input term to input text box
          Ned Murphy Adobe Community Professional & MVP

          The code you show seems to have syntax issues regarding the curly braces you show... I'd expect errors for that.

           

          The 1009 error indicates that one of the objects being targeted by your code is out of scope.  This could mean that the object....

          - is not in the display list

          - doesn't have an instance name (or the instance name is mispelled)

          - does not exist in the frame where that code is trying to talk to it

          - is animated into place but is not assigned instance names in every keyframe for it

          - is one of two or more consecutive keyframes of the same objects with no name assigned in the preceding frame(s).


          If you go into your Publish Settings Flash section and select the option to Permit debugging, your error message should have a line number following the frame number which will help you isolate which object is involved.


          • 2. Re: Trouble assigning more than one input term to input text box
            kirrwed Level 1

            Thanks, I tried that but the response was a little vague.  It just added a "MainTimeline::frame1:6" at the end, but I have several scenes in there, and I don't know what that means or which scene causes the problem.  But the good news is, that #1009 error only shows up when I do a command-Enter test run.  If I open the exported SWF in a browser, it all runs fine.  :shrug:

            • 3. Re: Trouble assigning more than one input term to input text box
              Ned Murphy Adobe Community Professional & MVP

              Without seeing the entire error message, you're stuck with what you can make of it yourself.