Globally styling anchor tags on a Spark RichEditableText control in Flex 4

The following example shows how you can globally style the normal and hover states of a hyperlink on a Flex 4 Spark RichEditableText control by setting the static TextFlow.defaultConfiguration object.

The following example(s) require Flash Player 10 and the Adobe Flex 4 SDK. To download the Adobe Flash Builder 4 trial, see To download the latest nightly build of the Flex 4 SDK, see

For more information on getting started with Flex 4 and Flash Builder 4, see the official Adobe Flex Team blog.

<?xml version="1.0" encoding="utf-8"?>
<!-- -->
<s:Application name="TextFlow_defaultConfiguration_test"
        import flashx.textLayout.elements.Configuration;
        import flashx.textLayout.elements.TextFlow;
        import flashx.textLayout.formats.TextDecoration;
        import flashx.textLayout.formats.TextLayoutFormatValueHolder;
        private function init():void {
            var cfg:Configuration = TextFlow.defaultConfiguration;
            var normalTLF:TextLayoutFormatValueHolder = new TextLayoutFormatValueHolder(cfg.defaultLinkNormalFormat);
            normalTLF.color = 0xFF0000;
            var hoverTLF:TextLayoutFormatValueHolder = new TextLayoutFormatValueHolder(cfg.defaultLinkHoverFormat);
            hoverTLF.color = 0xFF00FF;
            hoverTLF.textDecoration = TextDecoration.NONE;
            var activeTLF:TextLayoutFormatValueHolder = new TextLayoutFormatValueHolder(cfg.defaultLinkActiveFormat);
            activeTLF.color = 0x00FF00;
            cfg.defaultLinkNormalFormat = normalTLF;
            cfg.defaultLinkHoverFormat = hoverTLF;
            cfg.defaultLinkActiveFormat = activeTLF;
            TextFlow.defaultConfiguration = cfg;
    <s:RichEditableText editable="false" width="300" horizontalCenter="0" verticalCenter="0">
                <s:p>In addition to <s:a href=""></s:a> you can check out my other mediocre blogs at <s:a href=""></s:a> and <s:a href=""></s:a>.</s:p>

View source is enabled in the following example.

This entry is based on a beta version of the Flex 4 SDK and therefore is very likely to change as development of the Flex SDK continues. The API can (and will) change causing examples to possibly not compile in newer versions of the Flex 4 SDK.

6 thoughts on “Globally styling anchor tags on a Spark RichEditableText control in Flex 4

  1. Hey!

    Any ideas how to apply a stylesheet to a TextFlow? Like the Label or Text components in Flex Halo…

    I just want to be able to do and have it figure out how to do the rest, is this possible?

    Thanks for your help.


  2. error 1: cfg.defaultLinkNormalFormat —>cfg.linkNormalFormatDefault
    error 2: cfg.defaultLinkHoverFormat —>cfg.linkHoverFormatDefault
    error 2: cfg.defaultLinkActiveFormat—>cfg.linkNormalFormatDefault

  3. Thanks for the sample.
    Is there anyway we can get rid of the hand cursor for just non-href anchor? Do we have any control on the hand cursor display in general?
    Thanks for any info.

  4. Is there a way to do the same with other html tags?

    I would realy like to add a stylesheet to a textarea like in the old days. Or some other way of controlling how the different element should work.

    I would like to define some bold text as well as defining the links globaly. But it seems like it is either, if I import html/tlf dynamicaly.

Comments are closed.