Defining tab stops on a Spark TextArea control in Flex 4

The following example shows how you can set up tab stops on a Spark TextArea control in Flex 4 by setting the tabStops style.

Full code after the jump.

The following example(s) require Flash Player 10 and the Adobe Flex 4 SDK. To download the Adobe Flash Builder 4 trial, see www.adobe.com/products/flex/. To download the latest nightly build of the Flex 4 SDK, see opensource.adobe.com/wiki/display/flexsdk/Download+Flex+4.

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"?>
<!-- http://blog.flexexamples.com/2009/09/29/defining-tab-stops-on-a-spark-textarea-control-in-flex-4/ -->
<s:Application name="Spark_TextArea_tabStops_test"
        xmlns:fx="http://ns.adobe.com/mxml/2009"
        xmlns:s="library://ns.adobe.com/flex/spark"
        xmlns:mx="library://ns.adobe.com/flex/halo">
 
    <s:VGroup horizontalCenter="0" verticalCenter="0">
        <s:Label text="Defined on TextArea:" />
        <s:TextArea tabStops="100 200 300" width="400" heightInLines="3">
            <s:p>0<s:tab/>100<s:tab/>200<s:tab/>300</s:p>
        </s:TextArea>
 
        <s:Label text="Defined on ParagraphElement:" height="50" verticalAlign="bottom" />
        <s:TextArea width="400" heightInLines="3">
            <s:p tabStops="100 200 300">0<s:tab/>100<s:tab/>200<s:tab/>300</s:p>
        </s:TextArea>
 
        <s:Label text="Defined on TextFlow:" height="50" verticalAlign="bottom" />
        <s:TextArea width="400" heightInLines="3">
            <s:textFlow>
                <s:TextFlow tabStops="100 200 300">
                    <s:p>0<s:tab/>100<s:tab/>200<s:tab/>300</s:p>
                </s:TextFlow>
            </s:textFlow>
        </s:TextArea>
    </s:VGroup>
 
</s:Application>

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.

One thought on “Defining tab stops on a Spark TextArea control in Flex 4

  1. Is it possible to set the ‘distance’ of a tab and apply it to all possible tabs at once? Like, specify one number (100 px for example) and each new tab will be 100 pixels ‘long’?

Comments are closed.