1 Reply Latest reply on Sep 29, 2009 5:05 AM by Ned Murphy

    [AS2] how to access a TextInput using its name?

    popotskie

      I want to change the text of a TextInput using its name for example.

       

      ("name1").text = "123"

       


      or is it possible to create an array of components?:

       

      txt[0].text = "123"

       

      how to do it? thanks in advance

        • 1. Re: [AS2] how to access a TextInput using its name?
          Ned Murphy Adobe Community Professional & MVP

          I'm not certain what your intention is, but if the instance name of the textfield is name1, then you can assign its text using:

           

          name1.text = "123";

           

          If you have an array of the instances, the same applies, so long as the array is assigned the instances and not string versions of their names.

           

          var txt:Array = new Array(name1);

           

          txt[0].text = "123";

           

          If you have an array with strings of the instances names, then you need to use bracket notation to have the strings interpretted as instances...

           

          var txt:Array = new Array("name1");

           

          this[txt[0]].text = "123";