13.08.2012 Views

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>ACTIONSCRIPT</strong> 3.0 DEVELOPER’S GUIDE<br />

Using the Text Layout Framework<br />

More Help topics<br />

Padding changes in TLF 2.0<br />

Formatting text with TLF<br />

Flash Player 10 and later, Adobe AIR 1.5 and later<br />

The flashx.textLayout.formats package contains interfaces and classes that allow you to assign formats to any<br />

FlowElem<strong>en</strong>t in the text flow hierarchy tree. There are two ways to apply formatting. You can assign a specific format<br />

individually or assign a group of formats simultaneously with a special formatting object.<br />

The ITextLayoutFormat interface contains all of the formats that can be applied to a FlowElem<strong>en</strong>t. Some formats apply<br />

to an <strong>en</strong>tire container or paragraph of text, but do not logically apply to individual characters. For example, formats<br />

such as justification and tab stops apply to whole paragraphs, but are not applicable to individual characters.<br />

Assigning formats to a FlowElem<strong>en</strong>t with properties<br />

Flash Player 10 and later, Adobe AIR 1.5 and later<br />

You can set formats on any FlowElem<strong>en</strong>t through property assignm<strong>en</strong>t. The FlowElem<strong>en</strong>t class implem<strong>en</strong>ts the<br />

ITextLayoutFormat interface, so any subclass of the FlowElem<strong>en</strong>t class must also implem<strong>en</strong>t that interface.<br />

For example, the following code shows how to assign individual formats to an instance of ParagraphElem<strong>en</strong>t:<br />

var p:ParagraphElem<strong>en</strong>t = new ParagraphElem<strong>en</strong>t();<br />

p.fontSize = 18;<br />

p.fontFamily = "Arial";<br />

Assigning formats to a FlowElem<strong>en</strong>t with the TextLayoutFormat class<br />

Flash Player 10 and later, Adobe AIR 1.5 and later<br />

You can apply formats to a FlowElem<strong>en</strong>t with the TextLayoutFormat class. You use this class to create a special<br />

formatting object that contains all of the formatting values you want. You can th<strong>en</strong> assign that object to the format<br />

property of any FlowElem<strong>en</strong>t object. Both TextLayoutFormat and FlowElem<strong>en</strong>t implem<strong>en</strong>t the ITextLayoutFormat<br />

interface. This arrangem<strong>en</strong>t <strong>en</strong>sures that both classes contain the same format properties.<br />

For more information, see TextLayoutFormat in the ActionScript 3.0 Refer<strong>en</strong>ce for the Adobe Flash Platform.<br />

Format inheritance<br />

Flash Player 10 and later, Adobe AIR 1.5 and later<br />

Formats are inherited through the text flow hierarchy. If you assign an instance of TextLayoutFormat to a<br />

FlowElem<strong>en</strong>t instance with childr<strong>en</strong>, the framework initiates a process called a cascade. During a cascade, the<br />

framework recursively examines each node in the hierarchy that inherits from your FlowElem<strong>en</strong>t. It th<strong>en</strong> determines<br />

whether to assign the inherited values to each formatting property. The following rules are applied during the cascade:<br />

1 Property values are inherited only from an immediate ancestor (sometimes called the par<strong>en</strong>t).<br />

2 Property values are inherited only if a property does not already have a value (that is, the value is undefined).<br />

Last updated 6/6/2012<br />

436

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!