The following example shows how you can set the left and/or right tracking on a Flex Gumbo TextBox object by setting the trackingLeft and trackingRight styles.
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″.
<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/12/17/setting-tracking-on-a-textbox-object-in-flex-gumbo/ -->
<Application name="TextBox_trackingLeft_test"
xmlns="http://ns.adobe.com/mxml/2009"
layout="vertical"
verticalAlign="middle"
backgroundColor="white">
<ApplicationControlBar dock="true">
<Form styleName="plain">
<FormItem label="trackingLeft:">
<HSlider id="slider1"
minimum="0"
maximum="20"
value="0"
snapInterval="1"
tickInterval="1"
liveDragging="true" />
</FormItem>
<FormItem label="trackingRight:">
<HSlider id="slider2"
minimum="0"
maximum="20"
value="0"
snapInterval="1"
tickInterval="1"
liveDragging="true" />
</FormItem>
</Form>
</ApplicationControlBar>
<Box backgroundColor="haloSilver" backgroundAlpha="0.4">
<Graphic>
<TextBox id="textBox"
text="The quick brown fox jumps over the lazy dog."
trackingLeft="{slider1.value}"
trackingRight="{slider2.value}"
textAlign="justify"
textJustify="interWord"
fontSize="16"
width="400" />
</Graphic>
</Box>
</Application>
View source is enabled in the following example.
You can also set the trackingLeft and trackingRight styles in an external .CSS file or <Style/> block, as seen in the following example:
<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/12/17/setting-tracking-on-a-textbox-object-in-flex-gumbo/ -->
<Application name="TextBox_trackingLeft_test"
xmlns="http://ns.adobe.com/mxml/2009"
layout="vertical"
verticalAlign="middle"
backgroundColor="white">
<Style>
TextBox {
trackingLeft: 10;
trackingRight: 20;
textAlign: "justify";
textJustify: "interWord";
fontSize: 16;
}
</Style>
<Box backgroundColor="haloSilver" backgroundAlpha="0.4">
<Graphic>
<TextBox id="textBox"
text="The quick brown fox jumps over the lazy dog."
width="400" />
</Graphic>
</Box>
</Application>
Or, you can set the trackingLeft and trackingRight styles using ActionScript, as seen in the following example:
<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/12/17/setting-tracking-on-a-textbox-object-in-flex-gumbo/ -->
<Application name="TextBox_trackingLeft_test"
xmlns="http://ns.adobe.com/mxml/2009"
layout="vertical"
verticalAlign="middle"
backgroundColor="white">
<Script>
<![CDATA[
import mx.events.SliderEvent;
private function slider1_change(evt:SliderEvent):void {
textBox.setStyle("trackingLeft", evt.value);
}
private function slider2_change(evt:SliderEvent):void {
textBox.setStyle("trackingRight", evt.value);
}
]]>
</Script>
<ApplicationControlBar dock="true">
<Form styleName="plain">
<FormItem label="trackingLeft:">
<HSlider id="slider1"
minimum="0"
maximum="20"
value="0"
snapInterval="1"
tickInterval="1"
liveDragging="true"
change="slider1_change(event);" />
</FormItem>
<FormItem label="trackingRight:">
<HSlider id="slider2"
minimum="0"
maximum="20"
value="0"
snapInterval="1"
tickInterval="1"
liveDragging="true"
change="slider2_change(event);" />
</FormItem>
</Form>
</ApplicationControlBar>
<Box backgroundColor="haloSilver" backgroundAlpha="0.4">
<Graphic>
<TextBox id="textBox"
text="The quick brown fox jumps over the lazy dog."
textAlign="justify"
textJustify="interWord"
fontSize="16"
width="400" />
</Graphic>
</Box>
</Application>
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.

{ 2 comments… read them below or add one }
Hey Peter,
Nice Blog — I just noticed your blog is licensed under Creative Commons — I think I’ve been copying code from your examples for a project I am working on….does this mean I have to attribute somewhere? I dont even know what I’ve done exactly =(
Tim Erwin,
You’re welcome to use the code wherever you want (commercial or otherwise). Well, unless you’re making a Flex Examples site/magazine/book and basically copy/pasting entire entries and not linking back to me at all.
Peter