To set the alignment for the second paragraph only, we apply the format to the first character in the second paragraph, which resides at index 23 : Text format : TextField Flash / Flex / ActionScript examples


Flash / Flex / ActionScript examples » TextField » Text format »

 

To set the alignment for the second paragraph only, we apply the format to the first character in the second paragraph, which resides at index 23


 


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, 23);
        addChild(t);
    }
  }
}

        



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


Flash / Flex / ActionScript examples

 Navioo TextField
» Text format