1 Reply Latest reply on Apr 17, 2009 12:58 AM by ATIF FAROOQ

    Advice re: concatenating a variable name

    jcahill23 Level 1

      Hi.

      I have a few <mx:TextArea> controls each with the id of txtArea0, txtArea1, etc.

      I'm trying to get the value of txtArea0.text, txtArea1.text by concatenating txtArea + i, where i is 0,1,2,3 and then putting the .text on the end.

      Despite trying plenty of different ways can't get it working.

       

      Cheers.

        • 1. Re: Advice re: concatenating a variable name
          ATIF FAROOQ Level 3

          hi,

            you may run a loop on the parent container of your textField.

              eg  name of container in which you have the textfields is myContainer

           

              var  textConcats:String="";
              var  inspectedObject:DisplayObject;
          
              for(var i:int=0;i<myContainer.numChildren;i++){
               inspectedObject=myContainer.getChildByName('text'+i);
               if( inspectedObject is TextArea){
                  textConcats+=inspectedObject['text'];
               }else{
                  break;
               }
              }