3 Replies Latest reply on Jun 4, 2010 6:44 AM by kglad

    Having problem with setting variable on a textfield

    Bola.orginal

      I'm using createTextField to create a textfield. I have also created a input textfield with a variable called textline1 (I don't create the inputfield with as).

      I want to display the letters in the created textfiled that I'm typing in the input field. So this in my AS coed:

      _root.createTextField("text1",1,100,100,300,100);

      text1.variable = textline1;

       

       

       

      format1 = new TextFormat();

      format1.color = 0xff0000;

      format1.size = 50;

      format1.bullet = false;

       

       

      text1.setTextFormat(format1);

      but it doesn't work. So anyone see the problem?

       

      (sorry for bad english)

        • 1. Re: Having problem with setting variable on a textfield
          kglad Adobe Community Professional & MVP

          that code has to execute after textline1 contains what you want.  and that's not going to happen until text is entered.  so, you have a timing issue.

           

          to resolve, use the textfield's onChanged() method.

          • 2. Re: Having problem with setting variable on a textfield
            Bola.orginal Level 1

            ok tanks, that solved the problem.  I've got another problem to. I want to have the dynamic box draggeble. So I'm trying to create the textfield inside a movieclip. But it dosen't work.

             

            The code I'm using is this:

             

            fontsize=20;

             

            myInputText_txt.onChanged = function(text1:TextField) {

             

            _root.myText_mc.createTextField("text_txt",1,100,100, 100,100);

             

            text_txt.variable = "text2";

             

            text2=text1.text;

             

             

             

            format1 = new TextFormat();

            format1.color = 0xff0000;

            format1.size = fontsize;

            format1.bullet = false;

             

            text_txt.setTextFormat(format1);

             

            };

            maby it creating the textfield but it dosen't show any letters, so can anyone see what I'am doing wrong?

            • 3. Re: Having problem with setting variable on a textfield
              kglad Adobe Community Professional & MVP

              i think you're going to have more problems if you continue using textfield variables.  you should not use them.  just use the text property of the textfield to reference its contents.

               

              but, if you want to continue, use:

               


              var tl:MovieClip=this;

              fontsize=20;

               

              myInputText_txt.onChanged = function(text1:TextField) {

               

              _root.myText_mc.createTextField("text_txt",1,100,100, 100,100);

               

              _root.myText_mc.text_txt.variable = tl["text2"];

               

              text2=text1.text;

               

               

               

              format1 = new TextFormat();

              format1.color = 0xff0000;

              format1.size = fontsize;

              format1.bullet = false;

               

              text_txt.setTextFormat(format1);

               

              };

               

              p.s.  please mark this thread as answered.