Using HTML-formatted text 151
• leading Specifies the amount of leading (vertical space) between lines; corresponds to
TextFormat.leading. (See TextFormat.leading on page 722.)
• leftmargin Specifies the left margin of the paragraph, in points; corresponds to
TextFormat.leftMargin. (See TextFormat.leftMargin on page 723.)
• rightmargin Specifies the right margin of the paragraph, in points; corresponds to
TextFormat.rightMargin. (See TextFormat.rightMargin on page 723.)
• tabstops Specifies custom tab stops as an array of non-negative integers; corresponds to
TextFormat.tabStops. (See TextFormat.tabStops on page 723.)
The following code example uses the
tabstops attribute of the <textformat> tag to create a
table of data with boldfaced row headers, as shown below:
To create a formatted table of data using tab stops:
1 Using the Text tool, create a dynamic text field that’s approximately 300 pixels wide and 100
pixels high.
2 In the Property inspector, enter table_txt in the Instance Name text box, select Multiline
from the Line Type menu, and select the Render Text as HTML option.
3 In the Timeline, select the first frame on Layer 1.
4 Open the Actions panel (Window > Development Panels > Actions) and enter the following
code in the Actions panel:
var rowHeaders = "<b>Name\t</b><b>Age\t</b><b>Department";
var row_1 = "Tim\t31\tIMD";
var row_2 = "Edwin\t42\tQA";
table_txt.htmlText = "<textformat tabstops='[100, 200]'>";
table_txt.htmlText += rowHeaders;
table_txt.htmlText += row_1;
table_txt.htmlText += row_2 ;
table_txt.htmlText += "</textformat>";
Note the use of the tab character escape sequence (\t) to add tabs between each “column” in
the table.
5 Select Control > Test Movie to test the movie.
Underline tag (<u>)
The
<u> tag underlines the tagged text.
This text is <u>underlined</u>.
The above code would render as follows:
This text is underlined.
Name Age Department
Tim 32 IMD
Edwin 46 Engineering