Flash. Text. Engine entry notes (1)

Source: Internet
Author: User
Tags addchild

One of the new features provided by Flash Player 10: powerful text typographical capabilities are undoubtedly one of the most complex features of Flash Player 10, and even Adobe feels too complicated, so that a textlayout framework is released to assist in development.
Developer.
I am also in the process of getting started. Let's leave the textlayout framework blank and start exploring at the bottom layer. Let's share my study notes here.

Section 1: Awesome, The textblock (
Flash
. Text. Engine. textblock)
What is textblock? As the name suggests, we can call it a text block. For example, a text block is stored in a text block, which only stores the content and format of the text, the length and area of the output text are determined only when output is required. Read the code.
:

VaR TXT: String = "this is a very long and very long text, even if it does not actually look long! ";
// Define the font and format of the element
VaR format: elementformat = new elementformat (New fontdescription ("Arial "));
// No unit. If the unit is as elegant as 12 Px in CSS
Format. fontsize = 12;
VaR textele: textelement = new textelement (txt, format );
// Create a text block and change the text element to its content
VaR textblock; textblock = new textblock ();
Textblock. content = textele;
/**
* In fact, textblock. createtextline has two parameters. The first parameter is the text object of the previous line.
* The second parameter is the width of the output text line. Here I randomly write a 50px
*/
VaR textline: textline = textblock. createtextline (null, 50 );
// Set the location of the text line
Textline. x = 10;
Textline. Y = 10;
Addchild (textline );
// Set the second line of text. Why is it the second line of text? Because the last line is specified as textline during createtextline.
VaR textline2; textline = textblock. createtextline (textline, 100 );
Textline2.x = 10;
Textline2.y = textline. Y + textline. height + 10;
Addchild (textline2 );


On the timeline of your flash cs4, write down the above Code for compilation and running to see what will happen? Don't forget to select the text to see the effect!
In the above code, we can also see the textline class, which is equivalent to a text line. A text block can output multiple text lines, the text lines can be placed anywhere on the stage as you like, and their order is also specified by you!
So today's sharing will come here first.
Next time I will share a powerful graphicelement, and work with the knowledge I shared today to achieve a more amazing effect!

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.