Mega Code Archive

 
Categories / Flash ActionScript / TextField
 

To set the alignment for the first paragraph in the text field only, we apply the format to the first character in the first par

package{   import flash.display.Sprite;   import flash.text.*;     public class Main extends Sprite{     public function Main(){         var t:TextField = new TextField(  );         t.width = 300;         t.border = true;                  t.text = "This is paragraph one.\nThis is paragraph two.";                  var alignFormat:TextFormat = new TextFormat(  );         alignFormat.align = TextFormatAlign.CENTER;                  t.setTextFormat(alignFormat, 0);         addChild(t);     }   } }