2 Replies Latest reply on Oct 29, 2009 8:33 PM by Rothrock

    gotoAndPlay only if certain number of buttons have been clicked

    Andymc7 Level 1

      I'm still working on my Jeopardy game. It's pretty much finished, all except for one little nagging problem. I made it so that if the down arrow key is pressed, the Final Jeopardy! screen appears. However, I do not want this screen to appear (which is on another frame) until all of the questions on the game board have been played (25 separate MC's with buttons). So, I figure what I need is some actionscript to prevent the user from accidently going to the Final Jeopardy! screen prematurly. I've tried different ways of accomplishing this with no luck. The method I'm currently attempting is to have a variable that contains a number, which increases every time one of the squares on the board is clicked. Then, when the variable reaches a certain value, allow the user to advance to the final jeopardy screen.I currently have this on the first frame of my gameboard movie clip:


      var FJtrigger = 0;                             
      onEnterFrame = function () {             
          if (FJtrigger<=24) {
          } else {
              gotoAndPlay("FJbtn");         (This is the frame where by button resides that allows the user to go to the Final Jeopardy screen.)


      So you see at this point, I ditched the idea of having each individual square on the board add 1 to the variable FJtrigger. My code for each button was something like:


      on (release) {

           FJtrigger ++;


      Then, of course my initial frame of the gameboard movie was:


      var FJtrigger = 0;

      if (FJtrigger>=24) {



      Sorry for such a long description, but if anyone has an easier way to accomplish with with AS, I would be very grateful.



        • 1. Re: gotoAndPlay only if certain number of buttons have been clicked
          Andymc7 Level 1

          Sorry, I forgot to mention that each button on the game board has a gotoAndPlay command on it's last frame that takes it back to the first frame, which is where the first code I posted is placed. That's of course why I figured the onEnterFrame function would increase the value of FJtrigger repeatedly.

          • 2. Re: gotoAndPlay only if certain number of buttons have been clicked
            Rothrock Level 5

            You figured wrong about onEnterFrame. I'm guessing that you think it means "when I enter this frame" — which is a completely understandable thing to think. However, what it really means is "do this repeatedly at the given frame rate." So if you are using the default frame rate of 12 fps, then in 2 seconds you will go over 24. If you want something to just happen once on a given frame you just put the code by itself.


            Oddly enough I just spent a week or so making a Jeopardy game for my work too. I'm sure mine has a very different structure, so whatever advice I'm giving you is probably colored by my experience. So take that for what it is worth.


            You could add one each time they click one of the buttons — assuming that they can't revisit the questions.