4 Replies Latest reply on May 31, 2011 4:44 AM by Ron Colmen

    loop

    Ron Colmen Level 2

      Can someone help me to fix this. It's not working.

       

      _root.contents.txtool_mc.black_mc.Input_Txt.onChanged = function() {

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

      this["_root.contents.tool_mc.tool_mc6.hammer_mc.my_Dyn_text"+i].text = _root.contents.txtool_mc.black_mc.Input_Txt.text;

      }

      // do something else

      };

        • 1. Re: loop
          Ned Murphy Adobe Community Professional & MVP

          Here are some basics regarding using the bracket notation that you should commit to memory...

           

          1) you always need to have some lead-in targeting, but it can be actual targets instead of "this" all the time

           

          _root.someMovie["someTextfieldName"].text

           

          2) a bracket set can only point to one object/element, so there are times when you might need to use more then one in series...

           

          _root["someMovieName"]["someTextfieldName"].text

           

          3) repeating 2, and adding that you should only have a string representation inside the brackets, not a series of instance names...

           

          _root.contents.tool_mc.tool_mc6.hammer_mc["my_Dyn_text"+i].text

          • 2. Re: loop
            Ron Colmen Level 2

            Thanks for the explanation Ned!!!

            • 3. Re: loop
              Ned Murphy Adobe Community Professional & MVP

              You're welcome Ron

              • 4. Re: loop
                Ron Colmen Level 2

                 

                Hi Ned,

                 

                Any ideas why isn't this loop working?

                 

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

                _root.contents.txtool_mc["fontypeT_mc"+v].my_Input_Txt6.onChanged = function() {

                _root.gm_mc["my_Dyn_Txt"+v].text = _root.contents.txtool_mc["fontypeT_mc"+v].my_Input_Txt6.text;

                 

                for (j=1;j<15;j++){

                _root.contents.txtool_mc["fontypeT_mc"+v].fontlib_mc["my_Dyn_numft"+j].text = _root.contents.txtool_mc["fontypeT_mc"+v].my_Input_Txt6.text;

                }

                }

                };

                 

                2. Also is there a way to make one movieclip to _.visible=true and the rest of the movieclicps _.visible=false in a loop?

                 

                e.g.

                for (i=1; i<fontzA.length; i++){

                    fontN[i].ivar=i;

                 

                var dyofnt_fmt12:TextFormat = new TextFormat();

                fontN[i].onRelease = function() {

                radioN[i]._visible=false;

                dyofnt_fmt12.font = fontzA[this.ivar];

                _root.gm_mc.my_Dyn_Txt6.setTextFormat(dyofnt_fmt12);

                _root.gm_mc.my_Dyn_Txt6.embedFonts = true;

                _root.gm_mc.my_Dyn_Txt6.setNewTextFormat(dyofnt_fmt12);

                 

                radioN[this.ivar]._visible=true;

                }

                };