Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
CHAPTER 7 Text and TextFlows The text components in Flex 4 have been updated to take advantage of the new text- rendering engine in Flash Player 10, referred to as the Flash Text Engine. To work with text in a Flex application, you'll want to use the new components that utilize the Text Layout Framework: TextArea , RichText , and RichEditableText . Each of these compo- nents provides different functionality in a Flex application. The Label component provides simple, lightweight, basic text functionality. Label supports all of the prop- erties of the GraphicElement , as well as bidirectional text and a limited subset of text formatting, but it doesn't support hypertext or inline graphics. The RichText control supports HTML and, unlike Label , uses the TextFlow object model. It supports multiple formats and paragraphs but not scrolling, selection, or editing. Lastly, RichEditable Text supports scrolling, selection, editing, and hyperlinks, as well as supporting all the functionality of the Label and RichText components. Label does not use the Text Layout Framework, relying solely on the Flash Text Engine, while the other two components leverage the Text Layout Framework built into Flex 4. The Text Layout Framework also introduces the TextFlow class, which is an XML document of FlowElement s that can be written using tags or using FlowElement classes. For instance, a paragraph within a TextFlow can be created using a <p> tag in a Text Flow XML document or by attaching a ParagraphElement directly to a TextFlow instance, because the <p> tag is converted to a ParagraphElement when the content of the Text Flow is rendered. The Text Layout Framework's core functionality is to create, render, manipulate, and edit TextFlow objects. Within a TextFlow , you can display plain text and HTML. You can also apply text formatting and CSS styles to control the font, text size, and spacing of text or properties of graphical objects using universal selectors, classes (the . operator), or IDs (the # operator). When using the subset of HTML that is supported by the Flash Player, you can load images and other SWF files into the player. Text formatting--that is, controlling the font size and color--can be done using CSS if you use the correct IFormatResolver and TextLayoutFormat objects. 185