3 Replies Latest reply on Nov 2, 2011 9:18 AM by kglad

    Multiple Arrays

    Ron Colmen Level 2

      Below is my code. It dosen't work though.

       

      What I want to achieve is:

      If "Apple": _root.A5, _root.B5, _root.C2, _root.D7 should change its color to FF0000

      If "Orange":_root.A34, _root.B21, _root.C14, _root.D11 should change its color to FF6600

      etc...

       

      var mgA:Array = [_root.A5, _root.A34, _root.B87];

      var mgB:Array = [_root.B5, _root.B21, _root.B17];

      var mgC:Array = [_root.C2, _root.C14, _root.C77];

      var mgD:Array = [_root.D7, _root.D11, _root.D70];

       

      var mgBW:Array = ["Apple", "Orange", "Mango", " Banana"];

       

      for (k=0; k<mgBW.length; k++) {

          mgB[k].kvar=k;

          var theItemNow = mgA[k]+","+mgB[k]+","+mgC[k]+","+mgD[k];

      colorchange = new Color(theItemNow);{

              if (mgBW[k]== "Apple"){

                  colorchange.setRGB(0xFF0000); //_root.A5, _root.B5, _root.C2, _root.D7 should change its color to FF0000

                  }

              if (mgBW[k]== "Orange"){

                 colorchange.setRGB(0xFF6600); //_root.A34, _root.B21, _root.C14, _root.D11 should change its color to FF6600

                 }

              if (mgBW[k]== "Mango"){

                 colorchange.setRGB(0x339900);

                 }

              if (mgBW[k]== "Banana"){

                 colorchange.setRGB(0xFFCC00);

                 }

      }

      }

        • 1. Re: Multiple Arrays
          kglad Adobe Community Professional & MVP

          i'm not sure you want to loop through mgBW but if you do, use:

           

           

          var mgA:Array = [_root.A5, _root.A34, _root.B87];

          var mgB:Array = [_root.B5, _root.B21, _root.B17];

          var mgC:Array = [_root.C2, _root.C14, _root.C77];

          var mgD:Array = [_root.D7, _root.D11, _root.D70];

          var mgArray:Array = [mgA,mgB,mgC,mgD];

           

          var mgBW:Array = ["Apple", "Orange", "Mango", " Banana"];

           

          for (k=0; k<mgBW.length; k++) {

              mgB[k].kvar=k;

          for(var i:Number=0;i<mgArray.length;i++){

           

          colorchange = new Color(mgArray[i][k]);

                  if (mgBW[k]== "Apple"){

                      colorchange.setRGB(0xFF0000); //_root.A5, _root.B5, _root.C2, _root.D7 should change its color to FF0000

                      }

                  if (mgBW[k]== "Orange"){

                     colorchange.setRGB(0xFF6600); //_root.A34, _root.B21, _root.C14, _root.D11 should change its color to FF6600

                     }

                  if (mgBW[k]== "Mango"){

                     colorchange.setRGB(0x339900);

                     }

                  if (mgBW[k]== "Banana"){

                     colorchange.setRGB(0xFFCC00);

                     }

          }

          }

           

          • 2. Re: Multiple Arrays
            Ron Colmen Level 2

            Thanks Kglad!!

            • 3. Re: Multiple Arrays
              kglad Adobe Community Professional & MVP

              you're welcome.