It now contains the text Layout Framework (Text Layout Framework (TLF), and TLF can be used
Spark text components, such as richtext, richeditabletext, textarea, and textinput.
Other components of the component, such as ComboBox and ComboBox, can contain a textinput control. Now you can refine the text and text streams
And can use your UI to implement a number of truly amazing applications. This framework is very extensive ....
Dizzy, it is estimated that you have read this article here and it is the same as me, It is endless confusion and helplessness, what should I do? Fortunately, after I studied it, I finally got it.
Let's talk about it as follows: The textarea control has a textflow attribute, which is like this. The following code is used:
<S: textarea id = "TXT" x = "185" Y = "122" textflow = "{textconverter. importtoflow (STR, textconverter. text_field_html_format)}">
</S: textarea>
If you write it in <FX: SCRIPT>, write it like this:
TXT. textflow = textconverter. importtoflow (STR, textconverter. text_field_html_format)
Here, txt is the Instance name of the textarea control, and STR is a character about htmltext;
Now let's give a complete generation:
<? XML version = "1.0" encoding = "UTF-8"?>
<S: Application xmlns: FX = "http://ns.adobe.com/mxml/2009"
Xmlns: S = "Library: // ns.adobe.com/flex/spark"
Xmlns: MX = "Library: // ns.adobe.com/flex/mx" minwidth = "955" minheight = "600" creationcomplete = "Init ()">
<S: textarea id = "TXT" x = "157" Y = "118"/>
<S: button id = "N" x = "360" Y = "334" label = "send"/>
<S: textinput id = "input" x = "167" Y = "332"/>
<FX: SCRIPT>
<! [CDATA [
Import flashx. textlayout. Conversion. textconverter;
[Bindable]
Private var STR: string;
Private function Init (): void
{
N. addeventlistener (mouseevent. Click, doclick );
}
Private function doclick (E: mouseevent): void
{
STR = "<font color = '# ff0000' size = '25' face = ' '>" + input. Text + "</font>"
TXT. textflow = textconverter. importtoflow (STR, textconverter. text_field_html_format)
}
]>
</FX: SCRIPT>
</S: Application>
Appendix:
Text_field_html_format: String-flashx. textlayout. Conversion. textconverter
-
HTML format. This constant can be used to import or export from textflow to textflow in HTML format. Text Layout Framework HTML support
flash.text
The flag and attribute subset supported by the textfield class in the package.
The following table lists the HTML tags and attributes supported by the Import and Export processes (the tags and attributes supported by textfield but not supported by the text Layout Framework are specifically described as not supported ):
Tag |
Description |
Anchor tag |
<a> Tags create hypertext links and support the following attributes:
target : Specify the name of the target window for page loading. Options include_self ,_blank ,_parent And_top ._self Specifies the current frame in the current window,_blank Specify a new window,_parent Specifies the parent level of the current frame, while_top Specifies the top frame in the current window.
href : Specify a URL. The URL can be an absolute or relative path (relative to the position of the SWF file that loads the page ).http://www.adobe.com The example indicates the absolute reference to the URL;/index.html Example: relative reference. The absolute URL must be prefixed with http: //; otherwise, flash regards it as a relative URL.Note:Unlike the textfield classlink Event. Not supported either.a:link ,a:hover Anda:active Style.
|
Bold label |
<b> The label displays text in bold. Bold must be used in the font used. |
Line feed label |
<br> Tag creates a line break in the text. |
Font label |
<font> Label specifies a font or a font list to display text. Font labels support the following attributes:
color : Only hexadecimal colors (#FFFFFF ) Value.
face : Name of the font to be used. As shown in the following example, you can specify a list of font names separated by commas. In this case, flash player selects the first available font. If the specified font is not installed on the local computer system, or the specified font is not embedded in the SWF file, flash player selects an alternative font.
size : Specifies the font size. You can use absolute pixel size (such as 16 or 18) or relative pounds (such as + 2 or-4 ).
letterspacing : Specify the spacing applied to the right of each character (manual padding fine-tuning), in pixels.
kerning : Specifies whether the padding fine-tuning is enabled or disabled. A non-zero value indicates that the padding fine-tuning is enabled, while a zero value indicates that the padding fine-tuning is disabled.
|
Image Tag |
Use Tag, which can embed external image files (JPEG, GIF, PNG), SWF files, and video clips into text. Tags support the following attributes:
src : Specifies the URL of an image or SWF file or the link identifier of the video clip element in the library. This attribute is required, and all other attributes are optional. External files (JPEG, GIF, PNG, and SWF files) can be displayed only after full download.
width : The width (in pixels) of the inserted image, SWF file, or video clip ).
height Height (in pixels) of the inserted image, SWF file, or video clip ).
Note:Unlike the textfield class, the following attributes are not supported:align ,hspace ,vspace ,id AndcheckPolicyFile . |
Italic label |
<i> The label displays the text in the label in italics. Italics must be used in the font used. |
List item label |
Note:Unlike the textfield class, list item labels are not supported. |
Section label |
<p> Label to create a new section.<p> Tags support the following attributes:
- Align: Specifies the alignment of text in a paragraph. The valid value is
left ,right ,justify Andcenter .
- Class: Specifies the class name that can be used to set the style.
|
Span tag |
<span> Tags support the following attributes:
- Class: Specifies the class name that can be used to set the style.
|
Text Format label |
Use<textformat> You can use the paragraph format of the textformat class in text fields to set the subset of attributes, including line spacing, indentation, margin, and Tab space. You can<textformat> Tags are used in combination with built-in HTML tags. <textformat> Tags have the following attributes:
indent : Specifies the indent from the left margin to the first character in the paragraph; correspondsTextFormat.indent . Positive and negative values are acceptable.
blockindent : Specifies the indentation of all rows applied to a section.
leftmargin : Specify the left margin of a paragraph (in lbs ).TextFormat.leftMargin .
rightmargin : Specifies the right margin of a paragraph (in lbs); correspondsTextFormat.rightMargin .
leading : Specify the line spacing (Row Height) between the upper and lower sides of a row, in pixels.
tabstops : Specifies a comma-separated list of tabs in a paragraph.
|
Underline label |
<u> The label adds an underscore to the label text. |