3 Replies Latest reply on Jan 14, 2010 12:53 PM by kglad

    How can I single out one of the for loops elements?

    baianomauricioct

      Hi all, let's see if you can help with one .... I have 6 buttons [btn0, btn1 ... btn5] I want to redirect the user that clicks on one of the buttons [btn4]. I want to send them to nextFrame(); when they click on btn4.

       

      Code:

       

      for (var i = 0; i<=5; i++) {
          eval("btn"+i).onRelease = function() {
              selectBtn(this);

       

              if (!tryAgain) {
                  if (correctAnswers >= btnCount) {
                      trace("YesBaby!");
                      //this._parent.gotoAndStop(nextFrame());
                  } else {
                      tryAgain = true;
                      mcFeedback.text = "Try Again.";
                  }
              } else if (tryAgain=false) {
                  //this.btnText.text = "Submit";
                  _root.page.hideMessageBoxes();
                  mcFeedback.text = "You've Got One More Chance!";

       

              } else {
                  mcFeedback.text = "load animation";
                  trace(this._name);
              }
          };
          function pictOpacity(pictAlpha:Number) {
              eval("mc"+i)._alpha = pictAlpha;
          }
          eval("btn"+i).onRollOver = function() {
              pictOpacity(0);
          };
          eval("btn"+i).onRollOut = function() {
              pictOpacity(100);
          };
      }

       

      Thank you in advance.

        • 1. Re: How can I single out one of the for loops elements?
          kglad Adobe Community Professional & MVP

          if your buttons are movieclip buttons:

           


           

          for (var i = 0; i<=5; i++) {

          this["btn"+i].ivar=i;
              eval("btn"+i).onRelease = function() {

          if(this.ivar==4){

          nextFrame()

          }

                  selectBtn(this);

           

                  if (!tryAgain) {
                      if (correctAnswers >= btnCount) {
                          trace("YesBaby!");
                          //this._parent.gotoAndStop(nextFrame());
                      } else {
                          tryAgain = true;
                          mcFeedback.text = "Try Again.";
                      }
                  } else if (tryAgain=false) {
                      //this.btnText.text = "Submit";
                      _root.page.hideMessageBoxes();
                      mcFeedback.text = "You've Got One More Chance!";

           

                  } else {
                      mcFeedback.text = "load animation";
                      trace(this._name);
                  }
              };
              function pictOpacity(pictAlpha:Number) {
                  eval("mc"+i)._alpha = pictAlpha;
              }
              eval("btn"+i).onRollOver = function() {
                  pictOpacity(0);
              };
              eval("btn"+i).onRollOut = function() {
                  pictOpacity(100);
              };
          }

           

          Thank you in advance.