The following example shows how you can set the text alignment for a Flex NumericStepper control by setting the textAlign style.
Full code after the jump.
<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/05/18/setting-the-text-alignment-in-a-numericstepper-control-in-flex/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
verticalAlign="middle"
backgroundColor="white">
<mx:Array id="arr">
<mx:Object label="left" />
<mx:Object label="center" />
<mx:Object label="right" />
</mx:Array>
<mx:ApplicationControlBar dock="true">
<mx:Form styleName="plain">
<mx:FormItem label="textAlign:">
<mx:ComboBox id="comboBox"
dataProvider="{arr}" />
</mx:FormItem>
</mx:Form>
</mx:ApplicationControlBar>
<mx:NumericStepper id="numericStepper"
textAlign="{comboBox.selectedItem.label}"
width="100" />
</mx:Application>
View source is enabled in the following example.
You can also set the textAlign style in an external .CSS file or <mx:Style /> block, as shown in the following snippet:
<mx:Style>
NumericStepper {
textAlign: right;
}
</mx:Style>
Or, you can set the textAlign style using ActionScript, as shown in the following snippet:
<mx:Script>
<![CDATA[
private function init():void {
numericStepper.setStyle("textAlign", "right");
}
]]>
</mx:Script>





There is an easy way to add leading zeros to the numeric stepper in mxml? [ie. 001, insted of 1]
vigil,
This should do it:
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="middle" backgroundColor="white"> <mx:Script> <![CDATA[ import mx.events.NumericStepperEvent; private var nsMask:String = "000"; private function formatNumber(evt:Event):void { var value:String = numericStepper.value.toString(); value = (nsMask + value).substr(-nsMask.length); numericStepper.mx_internal::inputField.text = value; } ]]> </mx:Script> <mx:NumericStepper id="numericStepper" minimum="0" maximum="255" value="3" width="100" textAlign="center" creationComplete="formatNumber(event);" change="formatNumber(event);" /> </mx:Application>Peter
Thank you very much Peter. It’s perfect! :)
its of loads of help