1 Reply Latest reply on Mar 14, 2008 10:36 AM by Brian_ONE

    TextInput binding is not updated when edited

    Brian_ONE Level 1
      I found the below example from the TextInput help from Adobe, while the TextInput value displays the original value of the myProp it does not update the value myProp when the text is edited by the user.

      Code:

      <?xml version="1.0"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml">

      <mx:Script>
      <![CDATA[
      import mx.controls.Alert;

      [Bindable]
      public var myProp:String="This is the initial String myProp.";

      protected function test():void {
      Alert.show(myProp);
      }
      ]]>
      </mx:Script>

      <mx:TextInput text="{myProp}"/>
      <mx:Button x="10" y="10" label="Button" click="test()"/>

      </mx:Application>

      How to reproduce:

      1) Start the application.
      2) Notice the value of the text field is "This is the initial String myProp.".
      3) Enter "new value" in the text field.
      4) Click the button, and you will see the value has not changed for the var myProp.
        • 1. Re: TextInput binding is not updated when edited
          Brian_ONE Level 1
          I am going to update my post, I have found that a binding can only be "one-directional", I guess because it would create a circular reference. So in my example the TextInput did not own the binding, rather the myProp owned the relationship - so if I updated the value of myProp then the TextInput value would change (but not the other way arround).

          So basically there can only be one source and one destination per binding, ONLY the source will listen for an event and will then update the destination. In my example the source was the myProp var, and the destination was TextInput.