title: How do I add style to a text field?
body: <p>When I press a button it prints a random string in the TextField, but I want to add style too. So I used TextFormat but it doesn't seem to be working. I'm not sure what is wrong, it just seems to ignore the text format.</p>
  
  <pre><code>import flash.text.TextField;
  import flash.text.TextFormat;
  var tf: TextField = new TextField();
  var format: TextFormat = new TextFormat();
  format.size = 18;
  format.align = TextFormatAlign.CENTER;
  format.bold = true;
  format.color = 0x555555;
  tf.setTextFormat(format);
  
  convob.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler);
  
  function fl_MouseClickHandler(event: MouseEvent): void {
  
      starters();
  
  
  addChild(tf);
  
  }
  
  function starters() {
  
  var random = Math.floor((Math.random() * 5) + 1);
  
  switch (random) {
  
      case 1:
          tf.text = "eiff";
          addChild(tf);
          break;
      case 2:
          tf.text = "fne";
          addChild(tf);
          break;
      case 3:
          tf.text = "fnfefe";
          addChild(tf);
          break;
      case 4:
          tf.text = "fnefewwe";
          addChild(tf);
          break;
      case 5:
          tf.text = "fneeeffvvv";
          addChild(tf);
      default:
          break;
  }
  
  }
  </code></pre>