3 Replies Latest reply on Sep 23, 2013 9:29 PM by kglad

    TextFormat

    Ron Colmen Level 2

      There are 5 buttons. Each button removes previously created textfields (previewTx) and creates a new textfield using an embeded font type.

       

      Below is the code. Is there better way of achieveing this?

       

      txX = 10

      txY = 0;

      txW = 530;

      txH = 20;

       

      var csFormat0:TextFormat = new TextFormat();

      csFormat0.font = "Times";

      csFormat0.size = 16;

      csFormat0.color = 0x000000;

      csFormat0.align = "center";

      function fontt0() {

      previewTx.removeTextField();

      this.createTextField("previewTx", 5000, txX, txY, txW, txH);

      previewTx.setNewTextFormat(csFormat0);

      fontInfo();

      }

       

      var csFormat1:TextFormat = new TextFormat();

      csFormat1.font = "arial";

      csFormat1.size = 16;

      csFormat1.color = 0x000000;

      csFormat1.align = "center";

      function fontt1() {

                previewTx.removeTextField();

      this.createTextField("previewTx", 5000, txX, txY, txW, txH); 

      previewTx.setNewTextFormat(csFormat1);

      fontInfo();

      }

       

      function fontInfo() {

                previewTx.embedFonts = true;

                previewTx.selectable = true;

                previewTx.text = "ABCDE";

                previewTx.border = true;

                previewTx.type = "input";

                previewTx.multiline = true;

                previewTx.wordWrap = true;

      }

       

      font0.onRelease = function () {

                          fontt0();

      }

      font1.onRelease = function () {

                          fontt1();

      }