1 Reply Latest reply on Jan 6, 2010 4:44 AM by RossRitchey

    Embedding Font.

    Sreelash Level 1

      Hi,

       

      I am creating 3 textFields dynamically, then how can i embed fonts. I tried with the following way, but not working. Can anybody help me?

       

       

      var imgWid:Number = listMC.imgMC._width;
          var imgHt:Number = listMC.imgMC._height;
          var imgX:Number = listMC.imgMC._x;
         
          var textMC:MovieClip = listMC.createEmptyMovieClip("textMC",1);   
          textMC._x = imgX + imgWid + 7;
          textMC._y = 7;
          var txtWid:Number = listMC._width - (imgX + imgWid + 10);
          //trace(txtWid)
         
          var Nam = infmnArr[indx]._Name;
          var Add = infmnArr[indx]._Address;
          var Off = infmnArr[indx]._Offer;
         
          var name_fmt:TextFormat = new TextFormat();   
          name_fmt.font = "arial";
          name_fmt.color = 0x06b8b4;
          var nameTxt:TextField = textMC.createTextField("nametxt",1,0,0,txtWid,15);
          nameTxt.embedFonts = true;
          nameTxt.border = true;
          nameTxt.selectable = false;
          nameTxt.autoSize = true;
          nameTxt.wordWrap = true;
          nameTxt.text = Nam
          nameTxt.setTextFormat(name_fmt);       
         
          var add_fmt:TextFormat = new TextFormat();   
          add_fmt.font = "arialAdd";
          add_fmt.color = 0x06b8b4;
          var addTxt:TextField = textMC.createTextField("addTxt",2,0,nameTxt._y+nameTxt._height+5,txtWid,15);
         
          addTxt.embedFonts = true;
          addTxt.border = true;
          addTxt.selectable = false;
          addTxt.autoSize = true;
          addTxt.wordWrap = true;
          addTxt.text = "GD";
          addTxt.setTextFormat(add_fmt);   

       

       

      Thanks and regards,

      Sreelash

        • 1. Re: Embedding Font.
          RossRitchey Level 4

          I believe that you need to set the textFormat before you set the text in order for the textFormat to display.  Also, you can use the same textFormat object for multiple fields if the format is the same.

           

          So:

           

          var imgWid:Number = listMC.imgMC._width;
              var imgHt:Number = listMC.imgMC._height;
              var imgX:Number = listMC.imgMC._x;
              
              var textMC:MovieClip = listMC.createEmptyMovieClip("textMC",1);    
              textMC._x = imgX + imgWid + 7;
              textMC._y = 7;
              var txtWid:Number = listMC._width - (imgX + imgWid + 10);
              //trace(txtWid)
              
              var Nam = infmnArr[indx]._Name;
              var Add = infmnArr[indx]._Address;
              var Off = infmnArr[indx]._Offer;
              
              var name_fmt:TextFormat = new TextFormat();    
              name_fmt.font = "arial";
              name_fmt.color = 0x06b8b4;
          
              var nameTxt:TextField = textMC.createTextField("nametxt",1,0,0,txtWid,15);
              nameTxt.embedFonts = true;
              nameTxt.border = true;
              nameTxt.selectable = false;
              nameTxt.autoSize = true;
              nameTxt.wordWrap = true;
              nameTxt.setTextFormat(name_fmt);        
              nameTxt.text = Nam
          
          
              var addTxt:TextField = textMC.createTextField("addTxt",2,0,nameTxt._y+nameTxt._height+5,txtWid,15);
              addTxt.embedFonts = true;
              addTxt.border = true;
              addTxt.selectable = false;
              addTxt.autoSize = true;
              addTxt.wordWrap = true;
              addTxt.setTextFormat(name_fmt);
              addTxt.text = "GD";
          
          

           

          Also, I presume that you have the font object in the Library with the appropriate Linkage settings?