0 Replies Latest reply on Apr 22, 2013 10:17 AM by cougheno

    Can you use two way data binding with view states conditionals?


      I'd like to use one component and have what data is shown and where the data is saved vary based on the currentState of the Application/Skin/etc.  It seems to work fine for displaying different data but when I introduce two way binding the set from the ui component back to the variable is never called.  I have a minimum case example showing what I'm trying to get working below.


      Thanks for any insight.


      <?xml version="1.0" encoding="utf-8"?>

      <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"



                <!-- Place non-visual elements (e.g., services, value objects) here -->

                <fx:String id="myVar1">1</fx:String>

                <fx:String id="myVar2">2</fx:String>




            <s:State name="state1"/>

            <s:State name="state2"/>






                  <s:Button label="State 1" click="{currentState='state1'}"/>

                  <s:Button label="State 2" click="{currentState='state2'}"/>




            <!-- Works As Expected but lots of duplicate code -->

            <s:FormItem label="MyVar1" includeIn="state1">

               <s:TextInput text="@{myVar1}"/>


            <s:FormItem label="MyVar2" includeIn="state2">

               <s:TextInput text="@{myVar2}"/>




            <!-- Display updates as expected, Set to myVar1 or MyVar2 is never called -->

            <s:FormItem label="State Based">