blog
{Some Little News}
VR
{Virtual Reality}
media
{Photos + Videos}
code
{Websites + Apps}
5core
{Five Core}
html tags & formatted text in Flex 4 [Gumbo]
Some days ago I became crazy trying to format some simple text into a RichEditableText in Flex 4. This is because the Adobe team is deeply changing the way of using text in this new release. Let’s try to understand more on this:
“The Spark architecture provides three text “primitives” — Label, RichText, and RichEditableText — as part of its pay-only-for-what-you-need philosophy. Label is the fastest and most lightweight because it uses only FTE, not TLF, but it is limited in its capabilities: no rich text, no scrolling, no selection, and no editing. RichText adds the ability to display rich text with complex layout, but is still completely non-interactive. RichEditableText is the slowest and heaviest, but offers most of what TLF can do. You should use the fastest text primitive that meets your needs.”
And what about this RichEditableText?
“RichEditableText, which is new with Flex 4, makes use of the new Text Layout Framework (TLF) library, which in turn builds on the new Flash Text Engine (FTE) in Flash Player 10. In combination, these layers provide text editing with high-quality international typography and layout.”
Okay, and now how do I format my text? Well, if it is static you can simply put TLF markup tags inside the RichEditableText tag, as in:
[code lang="xml"]<s:RichEditableText>Hello <s:span fontWeight="bold">World!</s:span></s:RichEditableText>[/code]
If it is some kind of dynamic text, for instance loaded form some xml files, just use normal HTML tags in the xml code:
[code lang="xml"]<link><![CDATA[Visit website: <a target='_blank' href='http://www.5core.it'>www.5core.it</a>.]]></link>[/code]
Remenber to use the CDATA wrapping to avoid messign around. Furthermore, if you are going to use any kind of line breaks (r,n,< p >,< br/ >) you have to set the lineBreak style to “explicit” otherwise they won’t work!
[code lang="xml"]<s:RichEditableText id="dynamicText" lineBreak="explicit"/>[/code]
more reference on this topic in here.







Pingback: tag html e formattazione testo in Flex 4 [ITA] | Some Little News