7 Replies Latest reply on Jun 18, 2008 1:24 AM by kglad

    mc and for loop


      i have a only one movie clip inside it a text area, and i need to duplicate it like ( 3 x 3 { three boxes in one line then the second line 3 boxes and third line 3 boxes } ) with a difference text .

      note: i'll load the data from xml ( the text ) , so i need to check the xmlNodes.length if it 4 nodes, will be 4 boxes ( 3 , and 1 in new line ) if it 6 , if it 9 bla bla bla

      Thanks a lot
        • 1. Re: mc and for loop
          Ned Murphy Adobe Community Professional & MVP
          Give the movieclip a linkage ID via the library \ (right click the symbol in the library) and then use the attachMovie method to dynamically add as many of the mc instances as needed.
          • 2. Re: mc and for loop
            mkayyali Level 1
            i know that , but how to add the boxes dynamically in a rows and each row include only a 3 boxes ...
            • 3. Re: mc and for loop
              kglad Adobe Community Professional & MVP
              if you're adding them to a component (like the textarea), the easiest way to control their placement is to create an empty movieclip that you add to your textarea. then add whatever you want, however you want, to that movieclip.
              • 4. mc and for loop
                mkayyali Level 1
                dear Kglad,

                my problem not in the mcLoader , my problem is how to duplicate a movieclip ( any movieclip ) in a rows { 3 in row } ... like the image thumbnail gallery , some thunmbnails sort as a rows , that what i need if you please my friend ...

                my question again : how to duplicate a mc i n a rows ( every 3 mcs in row next 3 mcs in new row down of first one ....... )

                can you please try this code ( add any mc and name it { myMc } :

                var i = 1;
                for (var i = 0; i<5; i++) {
                duplicateMovieClip("square", "square"+i, i);
                squareName = eval("square"+i);
                xSpace = square._x;
                squareName._x = xSpace+(i*80);

                now , you will c that your mc is duplicated 5 times , i need last 2 mcs to be in a new row below the first 3 mcs ...

                Thanks a lot for your effort guys ...
                • 5. Re: mc and for loop
                  kglad Adobe Community Professional & MVP

                  • 6. Re: mc and for loop
                    mkayyali Level 1
                    kglad, thats awesome , thanks a millllllion, but can you please explain to me how thats work .
                    • 7. Re: mc and for loop
                      kglad Adobe Community Professional & MVP
                      i%N is the fractional part of i/N

                      Math.floor(i/n) = i - i%N

                      once you understand the two lines above, you'll understand how to create a rectangular grid.