3 Replies Latest reply on Jun 7, 2013 7:40 AM by kglad

    How to change the transparency of a grid square using attachMovie

    Pippa01 Level 1

      Hi,

       

      I've used a couple of 'for' loops to create a grid of squares using attachMovie. I want to be able to roll over one of those squares and only have that square decrease in transparency by 50%. What's happening instead, is that if I rollover any of the squares, only the alpha of the bottom right square is affected.

       

      Below is the code (I did try to insert it as an image, but I wasn't able to).

       

       

      onEnterFrame = function() {

       

      //set up grid for solid array

       

      SPACING = 1;

      COLS2 = 6; // number of columns in grid

      ROWS2 = 6; // number of rows in grid

      LEFTMARGIN2 = 100;

      TOPMARGIN2 = 100;

      DEPTH = 500; // starting point for depth

       

       

      for (m=1; m<=ROWS2; m++) {                                                                                                                                                      //open 1

      for (n=1; n<=COLS2; n++) {                                                                                                                                                                //open 2

      current2 = attachMovie("squareTest_mc", "squareTest_mc"+m+"_"+n, DEPTH++);

      current2._x = LEFTMARGIN2 + ((m-1) * (SPACING + current2._width));

      current2._y = TOPMARGIN2 + ((n-1) * (SPACING + current2._height));

       

      current2.onRollOver = function() {

                 current2._alpha=50;

      }

       

                }

                 } 

       

      }

       

       

      I'm using Mac OS 10.6, CS3

       

      I'd really appreciate some help.

       

      Many thanks,

      Philippa

        • 1. Re: How to change the transparency of a grid square using attachMovie
          kglad Adobe Community Professional & MVP

          1.  that should not be in an onEnterFrame loop.

           

          2. use:

           

           

           

           

          //set up grid for solid array

           

          SPACING = 1;

          COLS2 = 6; // number of columns in grid

          ROWS2 = 6; // number of rows in grid

          LEFTMARGIN2 = 100;

          TOPMARGIN2 = 100;

          DEPTH = 500; // starting point for depth

           

           

          for (m=1; m<=ROWS2; m++) {                                                                                                                                                       //open 1

          for (n=1; n<=COLS2; n++) {                                                                                                                                                                 //open 2

          current2 = attachMovie("squareTest_mc", "squareTest_mc"+m+"_"+n, DEPTH++);

          current2._x = LEFTMARGIN2 + ((m-1) * (SPACING + current2._width));

          current2._y = TOPMARGIN2 + ((n-1) * (SPACING + current2._height));

           

          current2.onRollOver = function() {

                     this._alpha=50;

          }

           

          current2.onRollOut = function() {

                     this._alpha=100;

          }

           

                    }

                     } 

           

           

           

          • 2. Re: How to change the transparency of a grid square using attachMovie
            Pippa01 Level 1

            Thank you. That was extremely helpful and a very fast response.