3 Replies Latest reply: Apr 30, 2012 2:22 PM by kglad RSS

    setTextFormat(format1);

    Ron Colmen Community Member

      The below code is inside _root.contents.text_mc

       

      I want to create a text field in _root.contents and when addText1 is clicked to change to format1. This is my code. It's not working. Can someone help fixing this?

       

      var format1:TextFormat = new TextFormat();

      format1.bold = true;

      format1.color = 0xFFFFFF;

      format1.size = 12;

      format1.font = "Font1";

       

      _root.contents.createTextField("newszlatest", this.getNextHighestDepth(), 0, 0, 0, 0);

      _root.contents.newszlatest.multiline = true;

      _root.contents.newszlatest.wordWrap = true;

      _root.contents.newszlatest.textColor = 0xFF6600;

       

      _root.contents.txtool_mc.droFonts_mc.font_mc.addText1.onRelease=function(){

                _root.contents.newszlatest.html=true;

           //trace ("Test...");

                _root.contents.newszlatest.setTextFormat(format1);

                 _root.contents.newszlatest.embedFonts = true;

                

                createTF(scrollup._x+tl.scrollup._width/2,scrollup._y,"");

                ft1.textColor = "0x666666"

                for (k=1; k<13; k++) {

                _root.contents.txtool_mc["ftI"+k]._visible=false;

      }

      }

        • 1. Re: setTextFormat(format1);
          kglad MVP

          i don't see any text assigned to newszlatest.  if there is none assigned until after you assign formatting, use setNewTextFormat(format1);

          • 2. Re: setTextFormat(format1);
            Ron Colmen Community Member

            Thanks Kglad.

             

            Also I tried to have newszlatest on the stage and remove _root.contents.createTextField("newszlatest", as per below code. Any idea why this didn't work?

             

            _root.contents.newszlatest.multiline = true;

            _root.contents.newszlatest.wordWrap = true;

            _root.contents.newszlatest.textColor = 0xFF6600;

             

            _root.contents.txtool_mc.droFonts_mc.font_mc.addText1.onRelease=function(){

                      _root.contents.newszlatest.html=true;

                 //trace ("Test...");

                      _root.contents.newszlatest.setNewTextFormat(format1);

                       _root.contents.newszlatest.embedFonts = true;

                     

                      createTF(scrollup._x+tl.scrollup._width/2,scrollup._y,"");

                      ft1.textColor = "0x666666"

                      for (k=1; k<13; k++) {

                      _root.contents.txtool_mc["ftI"+k]._visible=false;

            }

            }

            • 3. Re: setTextFormat(format1);
              kglad MVP

              if you're going to embed fonts for a dynamically created textfield, you need to assign a font (that's in your library and marked for export with actionscript).