6 Replies Latest reply on May 24, 2007 7:06 AM by Gorka Ludlow

    Help Needed for Beginner

    rallen2006 Level 1
      HI

      I am trying to create a whole simulation and im having problems wiht some aspects.

      One is with a measuremnet swf i have. Basically it plays a video and the user has to enter the correct value into an input text area . I want it to give them three attempts and then it loads an external swf with some help guides and tips.

      MY question is, how do i get it to count three incorrect entries and then close itself down and load another swf.

      My code so far (whic works bar the three attempts) is

      stop();


      _root.submit_micrometer_btn.onRelease=function() {
      if (_root.micrometer_answer_txt.text=="9.18") {
      _root.unloadMovie();
      } else {_root.response.text="Incorrect Answer Please Try Again"
      }
      };


      PLease help!

      Thank you

      Becki
        • 1. Re: Help Needed for Beginner
          kglad Adobe Community Professional & MVP
          when you load your external swf do you want to unload the measurement swf?
          • 2. Re: Help Needed for Beginner
            rallen2006 Level 1
            yes if possible i have no idea how to get the whole thing working and its driving me mad (along with the rest of it as well!)
            • 3. Re: Help Needed for Beginner
              Gorka Ludlow
              how about this:

              stop();

              var error_count:Number=0;
              _root.submit_micrometer_btn.onRelease=function() {
              if (_root.micrometer_answer_txt.text=="9.18") {
              _root.unloadMovie();
              } else {_root.response.text="Incorrect Answer Please Try Again"
              error_count++;
              if(error_count==3){
              _root.loadMovie('external_swf.swf',0);
              }
              }
              };

              Cheers
              Gorka
              • 4. Re: Help Needed for Beginner
                Rothrock Level 5
                Well, how would you do it if you had to sit there and watch and count? The same would be for Flash.

                You know that eveybody starts with zero tries, so:

                numAttempts=0;

                Then everytime they try and answer they have attempted it one more time. So inside the onRelease function.

                numAttempts++;

                If it is right you don't care so inside the first part of the if you don't need anything. But if they didn't get it right then you need to check how many times. So put something inside the else statement:

                if(numAttempts>=maxTries){
                trace("You've tried too many times. Let me help you.")
                } else {
                trace("Incorrect answer, please try again.");
                }

                Oh, I didn't mention maxTries. Generally I find that things like this get changed at the last minute, so it is easier to define a maxTries variable up at the top. Otherwise you end up going blind looking through all those lines of code.
                • 5. Help Needed for Beginner
                  rallen2006 Level 1
                  Brilliant this has worked thank you Gorka Ludlow :)

                  Only one more quesiont....how would i get the input text field to clear after each attempt? at the moment it stays there



                  stop();

                  var error_count:Number=0;
                  _root.submit_micrometer_btn.onRelease=function() {
                  if (_root.micrometer_answer_txt.text=="9.18") {
                  _root.unloadMovie();
                  } else {_root.response.text="Incorrect Answer Please Try Again"
                  error_count++;
                  if(error_count==3){
                  _root.loadMovie("introduction.swf");
                  }
                  }
                  };
                  • 6. Re: Help Needed for Beginner
                    Gorka Ludlow Level 1
                    With one simple instruction:

                    stop();
                    var error_count:Number=0;
                    _root.submit_micrometer_btn.onRelease=function() {
                    if (_root.micrometer_answer_txt.text=="9.18") {
                    _root.unloadMovie();
                    } else {
                    // this is it
                    _root.micrometer_answer_txt.text = '';
                    _root.response.text="Incorrect Answer Please Try Again"
                    error_count++;
                    if(error_count==3){
                    _root.loadMovie("introduction.swf");
                    }
                    }
                    };

                    Cheers
                    Gorka