To set the alignment for the first paragraph in the text field only, we apply the format to the first character in the first paragraph, which resides at index 0: : text format « TextField « Flash / Flex / ActionScript

Flash / Flex / ActionScript
1. Animation
2. Array
3. Class
4. Data Type
5. Development
6. Function
7. Graphics
8. Language
9. Network
10. Regular Expressions
11. Statement
12. String
13. TextField
14. XML
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Flash / Flex / ActionScript » TextField » text format 
To set the alignment for the first paragraph in the text field only, we apply the format to the first character in the first paragraph, which resides at index 0:
 

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);
    }
  }
}

        
Related examples in the same category
1. Change Text format
2. Formatting User-Input Text
3. Formatting a Portion of Existing Text
4. Setting a Text Field's Font
5. Use the TextFormat object's color and underline properties
6. Embedded font warning: Bold and italic require separate fonts
7. setTextFormat( ) does not apply to future text assignments
8. 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:
9. To set the alignment for a range of paragraphs, we apply the format using beginIndex and endIndex arguments that include the desired paragraphs:
10. Apply alignment formatting to the entire span of characters in the second paragraph.
11. Retrieving formatting information for a span of characters
12. If a specific format (e.g., font, bold, or italic) is not the same for all characters in a specified span, the corresponding variable of the TextFormat object for that span will be null
13. Default formatting for text fields
14. Set text format by searching the substring in textfield
15. The format for an empty TextField object is specified by assigning a TextFormat object to the TextField object's defaultTextFormat variable
16. Two formats
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.