Styling the text selection format on a Spark TextArea control in Flex 4

The following example shows how you can style the text selection format on a Spark TextArea control in Flex 4 by setting the focusedSelectionFormat property on the TextFlow’s interactionManager to a new SelectionFormat 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="Spark_ISelectionManager_focusedSelectionFormat_test"
            import flashx.textLayout.edit.ISelectionManager;
            import flashx.textLayout.edit.SelectionFormat;
            protected function txtFocusInHandler(evt:FocusEvent):void {
                var fSelFmt:ISelectionManager = evt.currentTarget.textFlow.interactionManager;
                fSelFmt.focusedSelectionFormat = new SelectionFormat(0x000000, 1.0, BlendMode.INVERT);
                evt.currentTarget.textFlow.interactionManager = fSelFmt;
    <s:TextArea id="ta"
            widthInChars="40" heightInLines="20"
            initialize="ta.text = describeType(ta).toXMLString();"
            horizontalCenter="0" verticalCenter="0" />

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.

2 thoughts on “Styling the text selection format on a Spark TextArea control in Flex 4

  1. I’m not entirely satisfied with this solution. I’m thinking there is probably a better way to override the SelectionFormat globally rather than on each text control individually. I’ll update this post if I find a better solution.


    1. Can use Skin appearance customization , so do not need to individually set each text control…

Comments are closed.