简体   繁体   中英

Flex: NumericStepper rounding up decimal number

I have the following NumericStepper:

<s:NumericStepper id="estimertTidCell" value="{isNaN(hostComponent.estimertTid)?0:hostComponent.estimertTid}" stepSize="0.5" maximum="5" change="hostComponent.estimertTid=estimertTidCell.value"/>

When i set the value to eg 1.5 through the NumericStepper and store the value, the alert in the following code correctly displays 1.5:

            private var _estimertTid:Number;


        [Bindable]
        public function get estimertTid():Number {
            return _estimertTid;
        }
        public function set estimertTid(value:Number):void {
            _estimertTid = value;
            Alert.show("numeric stepper set:" + value);
            invalidateSkinState();
        }

Problem: My problem is that once the NumericStepper refreshes, or reloads the variable, it displays 2 instead of 1.5, or 4 instead of 3.5 etc. Anyone got any ideas of what is causing this behavior? I would think that by setting the stepSize=0.5 it would correctly display those decimal numbers.

Additional information: When i display the same variable in a spark Label, the value is correctly displayed as a decimal number.

At last! I found a small note that snapInterval has to be set to the same as stepSize or the value will be rounded up. So i hope my troubles help someone else in the future. Set snapInterval to the same as stepSze to avoid numbers rounding up

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM