2 Replies Latest reply on May 11, 2010 7:32 AM by Rothrock

    setValue Problem within a textfield

    DazFaz Level 1

      Hi,

       

      This works

      _myMov._childMov._TextField.setValue("My Value")

       

      this does NOT work

      _myMov["_childMov._TextField"].setValue("My Value")

       

      The problem is that I have an array of strings that will represent paths to embedded text fields:

      This code does NOT work for some reason.

       

      var myArray:Array = ["_childMov1._TextField","_childMov2._TextField","_childMov3._TextField"]

      for(var i in myArray){

           _myMov[myArray[i]].setValue("My Value")

      }

       

      Does anyone have any ideas on this one?

       

      Thanks in advance.

        • 1. Re: setValue Problem within a textfield
          Rothrock Level 5

          That is because there is no object inside of _myMov called "_childMov._TextField". You can't have a period in the middle of a name so I'm certain of that. If you want to do it like this you can do it like so:

           

           

          _myMov["_childMov"]["_textField"].setValue("My Value");

           

          If you need to you could use string functions to break up the variable at the dot.

          1 person found this helpful
          • 2. Re: setValue Problem within a textfield
            Rothrock Level 5

            But if they are all the same this would be better:

             

             

            var numChildren=3;

            for(var i=0;i<numChildren;i++){

                 var curField:TextField=_myMov["_childMov"+i]._textField

                 curField.setValue();

                 // do what ever else  you want with curField

            }

             

            Learn to start counting from zero it will help you in the long run.

            1 person found this helpful