3 Replies Latest reply on Mar 26, 2007 9:35 PM by kglad

    array of texfields

    asden Level 1
      I can't work out how to create an array of textfields and populate a container with them. I'm using AS3 but it may not be as3 specific issue. Creating the array of textfields is the problem, the rest (addChild, x,y) should be ok.
        • 1. Re: array of texfields
          Recaf Level 1
          I'm not sure if it's the same is AS3, but in AS2 you can use an for...in loop to find all the TextFields and put them into an Array (replace "this" with the MovieClip/Sprite to search for TextFields):

          for (var a:String in this)
          if (this[a] instanceof TextField) textFields.push(this[a]);

          Hope that helps!


          Mesmotronic Multiuser Server for Flash 1.0 available now!
          • 2. Re: array of texfields
            asden Level 1
            Thanks, that's actually useful for another part of the code, but for this issue I want to create the textfields dynamically. In AS2 it would be something like
            for(i=0;i<5;i++) {

            In AS3 for a single textfield its:
            var txt:TextField = new TextField();

            How do I loop that in AS3. Naming the textfields into an array is the issue. The following doesn't work:

            for(var i = 0 ; i < 5 ; i++ ) {
            var this[ "txt" + i ]:TextField = new TextField();
            • 3. Re: array of texfields
              kglad Adobe Community Professional & MVP