5 Replies Latest reply on Aug 18, 2010 12:44 PM by kglad

    removeTextField();

    Ron Colmen Level 2

      Is there a way to remove all the text fields which was created? I used instance.removeTextField() but still I see some text boxes.

       

      In my fla when I go back and forth between frames I still see there are text boxes by the text cursor appearance. I'm having trouble because the buttons can not be clicked when the text fields are there.

       

      I'm using several of these in different frames.

       

      this.createTextField("scroll_txt", this.getNextHighestDepth(), 0, 0, 0, 0);

      this.createTextField("newszlatest", this.getNextHighestDepth(), 143, 170, 648, 233);

        • 1. Re: removeTextField();
          kglad Adobe Community Professional & MVP

          create an array to store your textfields and store their references in that array.  then loop through that array (from end to beginning) and remove them when you want:

           

          // these lines should execute once only at the start of your fla to initialize tfA and removeTF()
          var tfA:Array = []; 
          function removeTF(){
          for(var i:Number=tfA.length-1;i>=0;i--){
          tfA[i].removeTextField();
          }
          }

           

          // then when you create tf's, store them:

           

          this.createTextField("scroll_txt", this.getNextHighestDepth(), 0, 0, 0, 0);

          this.createTextField("newszlatest", this.getNextHighestDepth(), 143, 170, 648, 233);

          tfA.push(scroll_txt);

          tfA.push(newszlatest);

           

          // then when you want to remove them all, call removeTF():

           

           

          • 2. Re: removeTextField();
            Ron Colmen Level 2

            Thank you Kglad.

             

            Also how can I set a font type when using this.createTextField?

            • 3. Re: removeTextField();
              kglad Adobe Community Professional & MVP

              create a textformat instance and assign it a font.  then assign the textformat to your textfield.

               

              to have this work for all users, you'll need to embed your font.  do you know how to embed a font?

              1 person found this helpful
              • 4. Re: removeTextField();
                Ron Colmen Level 2

                Thanks once again.

                 

                this.createTextField("newszlatest", this.getNextHighestDepth(), 143, 170, 648, 233);

                newszlatest.multiline = true;

                newszlatest.wordWrap = true;

                newszlatest.textColor = 0xFFFFFF;

                 

                var format2:TextFormat = new TextFormat();

                format2.font = "Arial";

                newszlatest.setTextFormat(format2);

                 

                p.s. yes - I know to embed a font.

                • 5. Re: removeTextField();
                  kglad Adobe Community Professional & MVP

                  you're welcome.