Mega Code Archive

 
Categories / Flash ActionScript / TextField
 

Change Text format

package {   import flash.display.Sprite;   import flash.text.TextField;   import flash.text.TextFormat;      public class Main extends Sprite {     public function Main(  ) {       var field:TextField = new TextField(  );       var formatter:TextFormat = new TextFormat(  );       formatter.bold = true;       // Bold the text       formatter.color = 0xFFFF00;  // Make the text yellow       formatter.blockIndent = 5;   // Adjust the margin by 5 points            field.setTextFormat(formatter);       field.text = "this is sample text";       field.setTextFormat(formatter);    // Formatting applied       field.text = "this is new text";   // No formatting applied       field.setTextFormat(formatter);    // Formatting reapplied       field.text += "appended text";     // Formatting removed            addChild(field);     }   } }