5 Replies Latest reply on Jun 2, 2011 5:52 AM by kglad

    arrays N loops

    Ron Colmen Level 2

      var fontzA:Array = ["BauhausMedium", "Haettenschweiler", "Machine BT"];

      var fontN:Array = [ft_01, ft_02, ft_03];

       

      for (i=1;i<7;i++){

       

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

          fontN[k].kvar=k;

        

      var dyofnt_fmt:TextFormat = new TextFormat();

      _root["contents.txtool_mc.fontypeT_mc"+i].fontN[k].onRelease = function() {

      //trace(dyofnt_fmt.font);

      dyofnt_fmt.font = fontzA[this.kvar];

      _root["gmbb_mc.my_Dyn_Txt"+i].setTextFormat(dyofnt_fmt);

      _root["gmbb_mc.my_Dyn_Txt"+i].embedFonts = true;

      _root["gmbb_mc.my_Dyn_Txt"+i].setNewTextFormat(dyofnt_fmt);

       

      _root["contents.txtool_mc.fontypeT_mc"+i].fontN[k]a._visible=false;

      _root["contents.txtool_mc.fontypeT_mc"+i].fontN[this.kvar]._visible=true;

      }

      }

      };

       

      I'm stucked here. I want the font type "BauhausMedium" to apply when ft_01 is clicked, font type "Haettenschweiler" to apply when ft_02 is clicked, etc...

      at the same time I want all" ft_01a", "ft_02a", "ft_03a" movieclips to hide except for the movieclip similar to the clicked button. E.g. if "ft_02" was clicked  ft_02a to be visible =true and rest to be visible = false (ft_01a, ft_03a).

        • 1. Re: arrays N loops
          Ron Colmen Level 2

          I tried few things but this is is were I'm right now. Could someone help me to fix this.

           

           

          var fontzA:Array = ["BauhausMedium", "Haettenschweiler", "Machine BT"]; // font names

          var fontN:Array = [ft_1, ft_2, ft_3]; //button names

           

          for (i=1;i<5;i++){

              fontN[i].ivar=i;

            

          var dyofnt_fmt:TextFormat = new TextFormat();

          _root.contents.txtool_mc.fontypeT_mc6.fontN[i].onRelease = function() {

          trace (fontN[i])

          //trace(dyofnt_fmt.font);

          dyofnt_fmt.font = fontzA[this.ivar];

          _root.gm_mc.my_Dyn_Txt6.setTextFormat(dyofnt_fmt);

          _root.gm_mc.my_Dyn_Txt6.embedFonts = true;

          _root.gm_mc.my_Dyn_Txt6.setNewTextFormat(dyofnt_fmt);

          _root.contents.txtool_mc.fontypeT_mc6["fta_"+i]._visible=false;

          _root.contents.txtool_mc.fontypeT_mc6.fontN[this.ivar]._visible=true;

          }

          };

          • 2. Re: arrays N loops
            prodigalmaster Level 2

            Use the built in 'if' statements.

            • 3. Re: arrays N loops
              kglad Adobe Community Professional & MVP

               

              var fontzA:Array = ["BauhausMedium", "Haettenschweiler", "Machine BT"]; // font names

              var fontN:Array = [ft_1, ft_2, ft_3]; //button names

              var dyofnt_fmt:TextFormat = new TextFormat();

              _root.gm_mc.my_Dyn_Txt6.embedFonts = true;

               

               

              for (i=1;i<5;i++){

                  fontN[i].ivar=i;

                

               

              fontN[i].onRelease = function() {

              dyofnt_fmt.font = fontzA[this.ivar];

              _root.gm_mc.my_Dyn_Txt6.setTextFormat(dyofnt_fmt);

              _root.gm_mc.my_Dyn_Txt6.setNewTextFormat(dyofnt_fmt);

              // i don't know what these last two lines are supposed to do so it's not clear they're doing it

              _root.contents.txtool_mc.fontypeT_mc6["fta_"+this.ivar]._visible=false;

              _root.contents.txtool_mc.fontypeT_mc6.fontN[this.ivar]._visible=true;

              }

              };

               

               

              • 4. Re: arrays N loops
                Ron Colmen Level 2

                Cheers Kglad!

                • 5. Re: arrays N loops
                  kglad Adobe Community Professional & MVP

                  you're welcome.