The following example shows how you can set the digit case on a Flex Gumbo TextBox object by setting the digitCase style.
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/18/setting-the-digit-case-on-a-textbox-object-in-flex-gumbo/ -->
<Application name="TextBox_digitCase_test"
xmlns="http://ns.adobe.com/mxml/2009"
layout="vertical"
verticalAlign="middle"
backgroundColor="white">
<Style>
@font-face {
src: url("assets/ArnoPro-Regular.otf");
fontFamily: "ArnoProRegEmbedded";
cff: true;
}
TextBox {
digitWidth: "default";
fontFamily: "ArnoProRegEmbedded";
fontLookup: "embeddedCFF";
fontSize: 64;
textAlign: "center";
textAlignLast: "right";
}
</Style>
<Script>
<![CDATA[
private function comboBox_change(evt:Event):void {
textBox.setStyle("digitCase", comboBox.selectedItem);
}
private function checkBox1_change(evt:Event):void {
textBox.setStyle("lineThrough", checkBox1.selected);
}
private function checkBox2_change(evt:Event):void {
var value:String = (checkBox2.selected) ? "underline" : "normal";
textBox.setStyle("textDecoration", value);
}
]]>
</Script>
<Declarations>
<NumberFormatter id="numFormatter" />
</Declarations>
<ApplicationControlBar dock="true">
<Form styleName="plain">
<FormItem label="digitCase:">
<ComboBox id="comboBox"
dataProvider="[default,lining,oldStyle]"
change="comboBox_change(event);" />
</FormItem>
<FormItem label="lineThrough:">
<CheckBox id="checkBox1"
selected="false"
change="checkBox1_change(event);" />
</FormItem>
<FormItem label="underline:">
<CheckBox id="checkBox2"
selected="false"
change="checkBox2_change(event);" />
</FormItem>
</Form>
</ApplicationControlBar>
<HSlider id="slider"
minimum="0"
maximum="132456"
value="1000"
snapInterval="1"
liveDragging="true"
width="300" />
<Graphic>
<TextBox id="textBox"
text="{numFormatter.format(slider.value)}"
digitCase="default"
width="{slider.width}" />
</Graphic>
</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.
