Apply alignment formatting to the entire span of characters in the second paragraph. : Text format : TextField Flash / Flex / ActionScript examples


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

 

Apply alignment formatting to the entire span of characters in the second paragraph.


 

package{
  import flash.display.Sprite;
  import flash.text.*;
  public class Main extends Sprite{
    public function Main(){
        var t:TextField = new TextField(  );
        t.width = 100;
        t.border = true;
        t.wordWrap = true;
        t.text = "This is paragraph one.nThis is paragraph two.";

        var alignFormat:TextFormat = new TextFormat(  );
        alignFormat.align = TextFormatAlign.CENTER;
        
        var firstParagraphStart:int 0;
        var firstParagraphEnd:int = t.getParagraphLength(firstParagraphStart)-1;
        var secondParagraphStart:int = firstParagraphEnd+1;
        var secondParagraphEnd:int = secondParagraphStart+ t.getParagraphLength(secondParagraphStart)-1;
        
        t.setTextFormat(alignFormat, secondParagraphStart, secondParagraphEnd);
        addChild(t);
    }
  }
}

        



Leave a Comment / Note


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


Flash / Flex / ActionScript examples

 Navioo TextField
» Text format