0

I have a service where a data is in String format and in my form I have a NumericStepper whose value is an integer. The question is that I need to make a bi-directional databinding with the DataType object that keep the value.

Is there any way I can parse the value?

Thanks in advance.

Apalabrados
  • 1,098
  • 8
  • 21
  • 38

1 Answers1

0

Just use casting to appropriate type, here is an example with binding on string value of textInput:

<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
               xmlns:s="library://ns.adobe.com/flex/spark" 
               xmlns:mx="library://ns.adobe.com/flex/mx">
    <s:VGroup>
        <s:NumericStepper id="stepper" />
        <s:TextInput id="input" text="{data}" change="{data = input.text}"/>
    </s:VGroup>

    <fx:Binding source="String(stepper.value)" destination="data"/>
    <fx:Binding source="int(data)" destination="stepper.value"/>

    <fx:Script>
        <![CDATA[

            [Bindable]
            public var data:String = "0";

        ]]>
    </fx:Script>
</s:Application>

UPD: Added bi-directional databinding by fx:Binding tag. So, stepper.value binds on the data property, and the data property binds stepper.value. TextInput in the example changes data property for testing.

Serge Him
  • 936
  • 6
  • 8