10 Replies Latest reply on Jul 21, 2010 12:42 PM by kglad

    count

    Ron Colmen Level 2

      on frame 1 I've got 10 movieclips and each movieclip has a toggle button to make it visible true and false.

       

      How do write the script to do the following on frame 10?

       

      if only 1 movieclip is visible make one_mc visible true

      if only 2 movieclips are visible make two_mc visible true

      if only 3 movieclips are visible make three_mc visible true

      ... so on for all 10 hope this make sense.

        • 1. Re: count
          kglad Adobe Community Professional & MVP

          loop through your movieclips and total the number whose visible property is true.

          1 person found this helpful
          • 2. Re: count
            Ron Colmen Level 2

            thanks. could you show me a sample.

            • 3. Re: count
              Ron Colmen Level 2

              this is what i managed to do so far.... help me with the coding.

               

              _root.ldrpdf20_mc._visible=false;

              _root.ldrpdf40_mc._visible=false;

               

              _root.sender_mc.sender.onRelease = function () {

              var myvis = ["one_outline", "two_outline", "three_outline", "four_outline", "five_outline", "six_outline"];

              var myvis:Number=0;

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

              myvis++;

              if(myvis==1){

              _root.ldrpdf20_mc._visible=true;

              }

              myvis++;

              if(myvis==2){

              _root.ldrpdf40_mc._visible=true;

              }

              };

              • 4. Re: count
                kglad Adobe Community Professional & MVP

                use:

                 

                var mcA:Array = [_root.ldrpdf20_mc,__root.ldrpdf40_mc, etc..];

                var myvisA:Array = ["one_outline", "two_outline", "three_outline", "four_outline", "five_outline", "six_outline"];

                 

                 

                _root.sender_mc.sender.onRelease = function () {

                var visNum:Number=0;

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

                if(mcA[i]._visible){
                visNum++
                }

                }

                myvisA[visNum]._visible=true;

                };

                • 5. Re: count
                  Ron Colmen Level 2

                  Thanks kglad. but the code dosen't seem to respond. This did not pick the correct movieclip... it always shows the "ldrpdf20_mc". I also tried by adding if(myvisA[i]._visible==true) but still no success.

                   

                  example of what i want to achieve: if "one_outline", "three_outline", "six_outline" are visible then make ldrpdf60_mc visible.

                   

                  on frame 10:

                  var mcA:Array = [_root.ldrpdf20_mc,_root.ldrpdf40_mc,_root.ldrpdf60_mc,_root.ldrpdf80_mc,_root.ldrpdf100_ mc,_root.ldrpdf120_mc];

                  var myvisA:Array = ["one_outline", "two_outline", "three_outline", "four_outline", "five_outline", "six_outline"];

                  _root.sender_mc.sender.onRelease = function () {

                  var visNum:Number=0;

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

                  if(myvisA[i]._visible==true){

                  visNum++

                  }

                  }

                  mcA[visNum]._visible=true;

                  };

                   

                  Thank you!

                  • 6. Re: count
                    kglad Adobe Community Professional & MVP

                    myvisA should be an array of movieclips, not strings:

                     


                     

                    var mcA:Array = [_root.ldrpdf20_mc,_root.ldrpdf40_mc,_root.ldrpdf60_mc,_root.ldrpdf80_mc,_root. ldrpdf100_mc,_root.ldrpdf120_mc];

                    var myvisA:Array = [one_outline, two_outline, three_outline, four_outline, five_outline, six_outline];

                    _root.sender_mc.sender.onRelease = function () {

                     

                    var visNum:Number=0;

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

                    if(myvisA[i]._visible==true){

                    visNum++

                    }

                    }

                    mcA[visNum]._visible=true;

                    };

                     

                    • 7. Re: count
                      Ron Colmen Level 2

                      Thank you kglad. 

                       

                      also how do I say do this if visNum=0

                       

                      blank_mc._visible=false;

                       

                      var mcA:Array = [_root.ldrpdf20_mc,_root.ldrpdf40_mc,_root.ldrpdf60_mc,_root.ldrpdf80_mc,_root.ldrpdf100_ mc,_root.ldrpdf120_mc];

                      var myvisA:Array = [one_outline,two_outline,three_outline,four_outline,five_outline,_six_outline];

                       

                      _root.sender_mc.sender.onRelease = function () {

                      var visNum:Number=0;

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

                      if(myvisA[i]._visible==true){

                      visNum++

                      }

                      }

                      }

                      mcA[visNum]._visible=true;

                      if(visNum==0){

                      blank_mc._visible=true

                      };

                      };

                      • 8. Re: count
                        kglad Adobe Community Professional & MVP

                        use:

                         

                         


                         

                        var mcA:Array = [blank_mc,_root.ldrpdf20_mc,_root.ldrpdf40_mc,_root.ldrpdf60_mc,_root.ldrpdf80_mc,_root. ldrpdf100_mc,_root.ldrpdf120_mc];

                        var myvisA:Array = [one_outline,two_outline,three_outline,four_outline,five_outline,_six_outline];

                         

                        _root.sender_mc.sender.onRelease = function () {

                        var visNum:Number=0;

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

                        if(myvisA[i]._visible==true){

                        visNum++

                        }

                        }

                        }

                        mcA[visNum]._visible=true;

                        if(visNum==0){

                        blank_mc._visible=true

                        };

                        };

                        1 person found this helpful
                        • 9. Thanks!
                          Ron Colmen Level 2

                          Thank you! I wish i could give you more than 20. 

                          • 10. Re: Thanks!
                            kglad Adobe Community Professional & MVP

                            you're welcome.