Use fte in as3 to render text (Quick Start to flash text engine)

Source: Internet
Author: User
Tags addchild

Many recent development
Users are paying attention to mobile games.
So let's take a look at a new feature (fp10). Using this method can solve cross-hardware problems.

FTE (flash text engine)

Fte provides low-level support for complex control over text measurements, formats, and bidirectional texts. FTE is designed to create text processing components for developers.
Provide the foundation. In the following simple example, you will find that using FTE is not complex.

Below
Code
Fp10 required


Package {
Import flash. display. Sprite;
Import flash. Text. textfield;
Import flash. Text. textformat;
Import flash. Text. Engine .*;
Public class FTE extends sprite {
Public Function FTE (): void {
// FTE Text
VaR font_description: fontdescription = new fontdescription ();
Font_description.fontname = "verdana ";
Font_description.fontweight = fontweight. Bold;
Font_description.fontposture = fontposture. italic;
Font_description.renderingmode = renderingmode. CFF;
Font_description.locked = true;
VaR element_format: elementformat = new elementformat (font_description );
Element_format.fontsize = 40;
Element_format.kerning = kerning. on;
Element_format.color = 0x000000;
Element_format.alpha = 1;
VaR text_element: textelement = new textelement ("Hello flash world", element_format );
VaR text_block: textblock = new textblock ();
Text_block.content = text_element;
VaR text_line: textline = text_block.createtextline (null, 500 );
Text_line.x = 20;
Text_line.y = 40;
Addchild (text_line );
// Normal text
VaR text_field: textfield = new textfield ();
VaR text_format: textformat = new textformat ();
Text_format.color = 0x000000;
Text_format.size = 40;
Text_format.bold = true;
Text_format.font = "verdana ";
Text_format.italic = true;
Text_field.x = 18;
Text_field.y = 30;
Text_field.width = 460;
Text_field.height = 60;
Text_field.text = "Hello flash world ";
Text_field.settextformat (text_format );
Addchild (text_field );
}
}
}


Lines 1 to 5:
Import the required class library.

Lines 9 to 14:

Use
Fontdescription

Class to define the font. By locking (14th rows) the font and setting the rendering mode to CFF (13th rows) to enhance text readability, in the case of a small font size effect
For more information, see the official documentation.

Lines 15 to 19:

Use
Elementformat

Class to set the format information. However, I have not used the new baseline alignment features mentioned in the document. Closing the padding adjustment will improve text readability.

20 rows:

Use
Textelement

Class to indicate the text strings that I want to display and have already set the format. This is nothing special.

Rows 21 to 22:

Textblock

Class will render itself, but its more function is about format and control.

23 to 25 rows:


Use textline

Class to display the content. As described in the document, it only has many read-only attributes.
.

23 to 40 rows:

Same operations as common text boxes

Our achievements are:

Download

(12.23 KB) yesterday

The above line uses FTE, and the following uses a common text box.
I have to admit that there is no significant difference between the two (in this example ).
The purpose of this example is to help you get started with FTE.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.