Setting tab stops in an FxTextArea control in Flex Gumbo

The following example shows how you can set tab stops in a Flex Gumbo FxTextArea control by setting the tabStops style to an array of TabStopFormat objects.

Full code after the jump.

To use the following code, you must have Flash Player 10 and a Flex Gumbo SDK installed in your Flex Builder 3. For more information on downloading and installing the Gumbo SDK into Flex Builder 3, see “Using the beta Gumbo SDK in Flex Builder 3”.

View MXML

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/10/31/setting-tab-stops-in-an-fxtextarea-control-in-flex-gumbo/ -->
<FxApplication name="FxTextArea_tabStops_test"
        xmlns="http://ns.adobe.com/mxml/2009"
        xmlns:formats="flashx.textLayout.formats.*">
    <layout>
        <BasicLayout />
    </layout>

    <Style>
        HBox {
            paddingLeft: 20;
            paddingRight: 20;
            paddingTop: 20;
            paddingBottom: 20;
        }
    </Style>

    <HBox width="100%" height="100%">
        <FxTextArea id="fxTextArea"
                width="100%"
                height="100%">
            <content>
                <String source="data/mlb2008.html" />
            </content>
            <tabStops>
                <formats:TabStopFormat alignment="start" />
                <formats:TabStopFormat alignment="end"
                        position="400" />
                <formats:TabStopFormat alignment="end"
                        position="500" />
            </tabStops>
        </FxTextArea>
    </HBox>

</FxApplication>

data/mlb2008.html

<!-- data/mlb2008.html -->
<p fontSize="18" textAlign="center">AL East</p>
<p fontWeight="bold">Team<tab/>W<tab/>L</p>
<p>Tampa Bay<tab/>97<tab/>71</p>
<p>Boston<tab/>95<tab/>67</p>
<p>New York<tab/>89<tab/>73</p>
<p>Toronto<tab/>86<tab/>76</p>
<p>Baltimore<tab/>68<tab/>93</p>

<p fontSize="18" textAlign="center">AL Central</p>
<p fontWeight="bold">Team<tab/>W<tab/>L</p>
<p>Chicago<tab/>89<tab/>74</p>
<p>Minnesota<tab/>88<tab/>75</p>
<p>Cleveland<tab/>81<tab/>71</p>
<p>Kansas City<tab/>75<tab/>87</p>
<p>Detroit<tab/>74<tab/>88</p>

<p fontSize="18" textAlign="center">AL West</p>
<p fontWeight="bold">Team<tab/>W<tab/>L</p>
<p>Los Angeles<tab/>100<tab/>62</p>
<p>Texas<tab/>79<tab/>83</p>
<p>Oakland<tab/>75<tab/>86</p>
<p>Seattle<tab/>61<tab/>101</p>

<p fontSize="18" textAlign="center">NL East</p>
<p fontWeight="bold">Team<tab/>W<tab/>L</p>
<p>Philadelphia<tab/>92<tab/>70</p>
<p>New York<tab/>89<tab/>73</p>
<p>Florida<tab/>84<tab/>77</p>
<p>Atlanta<tab/>72<tab/>90</p>
<p>Washington<tab/>59<tab/>102</p>

<p fontSize="18" textAlign="center">NL Central</p>
<p fontWeight="bold">Team<tab/>W<tab/>L</p>
<p>Chicago<tab/>97<tab/>64</p>
<p>Milwaukee<tab/>90<tab/>72</p>
<p>Houston<tab/>86<tab/>75</p>
<p>St. Louis<tab/>86<tab/>76</p>
<p>Cincinnati<tab/>74<tab/>88</p>
<p>Pittsburgh<tab/>67<tab/>95</p>

<p fontSize="18" textAlign="center">NL West</p>
<p fontWeight="bold">Team<tab/>W<tab/>L</p>
<p>Los Angeles<tab/>84<tab/>78</p>
<p>Arizona<tab/>82<tab/>80</p>
<p>Colorado<tab/>74<tab/>88</p>
<p>San Francisco<tab/>72<tab/>90</p>
<p>San Diego<tab/>63<tab/>99</p>

View source is enabled in the following example.

This entry is based on a beta version of the Flex Gumbo 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 Gumbo SDK.