Flash. Text. Engine entry notes (2)

Source: Internet
Author: User

Review flash
What are the defects of the. Text. textfield class in text/Text mixing?
I believe that many people think that the structure of the description is too poor, images do not support inline, and it will be very troublesome to change the image in the text area (although flash. text. engine is also not easy to see ).
First, we will introduce the graphicelement class. This class, as its name implies, is an image element. It is purely a phenotype element. It is equivalent to IMG in HTML, but it does not have the image reading function. It can only read external images through loader, then, the loader is used as its content.
Take a look at the following instance code
:

// Draw a red rectangle as our image
VaR shape: Shape = new shape ();
Shape. Graphics. beginfill (0xff0000 );
Shape. Graphics. drawrect (0, 0,100,100 );
Shape. Graphics. endfill ();
// Create an image element and use our shape as its display content. It can also become a loader.
VaR graphicele: graphicelement = new graphicelement (shape, shape. Width, shape. Height );
// Create a text block for loading image elements and outputting rows
VaR textblock: textblock = new textblock ();
Textblock. content = graphicele;
VaR textline: textline = textblock. createtextline (null, 200 );
Textline. x = 100;
Textline. Y = 100;
Addchild (textline );

The above example has briefly introduced the use of the graphicelement class. How can we achieve the image inline text-and-image mixing? A groupelement class is provided in flash. Text. engine, which combines all elements and then looks at the following code:

// Draw a red rectangle as our image
VaR shape: Shape = new shape ();
Shape. Graphics. beginfill (0xff0000 );
Shape. Graphics. drawrect (0, 0,100,100 );
Shape. Graphics. endfill ();
// Create an image element and use our shape as its display content. It can also become a loader.
VaR graphicele: graphicelement = new graphicelement (shape, shape. Width, shape. Height );
// Create a text element
VaR format: elementformat = new elementformat (New fontdescription ("Arial "));
Format. fontsize = 12;
VaR textele: textelement = new textelement ("Hello world! ", Format );
// Drop all the elements just created into a vector and combine them into a group of elements
VaR elevector: vector. <contentelement> = new vector. <contentelement> ();
Elevector. Push (textele, graphicele );
VaR groupele: groupelement = new groupelement (elevector );
// Create a text block for loading image elements and outputting rows
VaR textblock: textblock = new textblock ();
Textblock. content = groupele;
VaR textline: textline = textblock. createtextline (null, 300 );
Textline. x = 100;
Textline. Y = 100;
Addchild (textline );

Through the above Code, you should be able to view the flash. text. engine has a general understanding of it, as for the layout details, I believe it does not need the younger brother to repeat it here, because textline makes everything easier, and the younger brother is not easy to learn, it is not as effective as directly checking the attributes of the help document.

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.