How do I determine whether a value set comes from user interaction with the input component, or from binding?

Example:

<s:NumericStepper xmlns=...
                  value="{SomeDataManager.foo}">
<fx:Script>
    override public function set value(newValue:Number):void {
        if (setByUser) {
            super.value = newValue;
        } else {
            // ...
        }
    }
</fx:Script>
</s:NumericStepper>

Using Flex 4.1 if that matters.

有帮助吗?

解决方案

listen for the change event. It will solve your problem.

<s:HGroup>
        <s:NumericStepper change="trace('ns change')" value="{ns2.value}" minimum="{ns2.minimum}" maximum="{ns2.maximum}"/>
        <s:NumericStepper minimum="0" maximum="1000" id="ns2" />
    </s:HGroup>

The change event gets fired when an input component's value is changed by user interaction. If some part of your code is changing that component's value, the change event will not get fired.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top