7 Replies Latest reply on Sep 18, 2013 6:51 AM by kglad

    [i]._visible

    Ron Colmen Level 2

      Below is my code. This dosen't seem to work even though capts[i] are all fasle. Where's the fault?

       

      var capts:Array = [purchaseH0, purchaseH1, purchaseH2, purchaseH3];

       

      for(i=0; i<capts.length; i++){

                _root["purchaseH"+i]._visible=false;

       

                nextStep_btn.onRelease = function () {

                          if(capts[i]._visible==false){

                                    trace("invisible")

                          } else {

                                    trace ("visible")

                          }

                          }

      }

      };

        • 1. Re: [i]._visible
          kglad Adobe Community Professional & MVP

          i=capts.length when that button is clicked.

           

          what are you trying to do when that button is clicked.  if you want to loop through capts, you'll need another for-loop.

          • 2. Re: [i]._visible
            Ron Colmen Level 2

            Thanks for the reply kglad.

             

            I used another for loop. But still the output is "visible".

             

            Also either it's  if(capts[i]._visible==false){  or if(capts[i]._visible==true){ the output is still 'visible'?

             

            var capts:Array = [purchaseH0, purchaseH1, purchaseH2, purchaseH3];

             

            for(i=0; i<capts.length; i++){

                      _root["purchaseH"+i]._visible=false;

            }

            for(i=0; i<capts.length; i++){

                      nextStep_btn.onRelease = function () {

                                if(capts[i]._visible==false){

                                          trace("invisible")

                                } else {

                                          trace ("visible")

                                }

                                }

            };

            • 3. Re: [i]._visible
              kglad Adobe Community Professional & MVP

              i still don't know what you're trying to do but the additional for-loop i mentioned above should be inside, the onRelease:

               

               

                        nextStep_btn.onRelease = function () {

                             for(i=0; i<capts.length; i++){

                                  if(capts[i]._visible==false){

                                            trace("invisible")

                                  } else {

                                            trace ("visible")

                                  }

                            }

              };

              • 4. Re: [i]._visible
                Ron Colmen Level 2

                Thanks Kglad. That worked. But I don't quite understand why does it make a difference when the for-loop is inside or outside the onRelease??

                 

                p.s.I'm using this to check if all mcs in capts is visible=false.

                • 5. Re: [i]._visible
                  kglad Adobe Community Professional & MVP

                  this code:

                   

                  for(i=0; i<capts.length; i++){

                            nextStep_btn.onRelease = function () {

                                      if(capts[i]._visible==false){

                                                trace("invisible")

                                      } else {

                                                trace ("visible")

                                      }

                                      }

                  };

                   

                  creates capts.length number of identical onRelease handlers.  in as2, only the last one is implemented.  it overrides the earlier ones, but you can't tell because all of them are identical.

                   

                  anyway, when you release nextStep_btn, i is equal to capts.length and there is no capts[i] object so that if-statement makes no sense to flash.  ie, that block of code makes no sense to flash.

                  1 person found this helpful
                  • 6. Re: [i]._visible
                    Ron Colmen Level 2

                    Thanks. That makes sense.

                    • 7. Re: [i]._visible
                      kglad Adobe Community Professional & MVP

                      you're welcome.