3 Replies Latest reply on May 25, 2009 4:39 PM by Michael Borbor

    Databinding question

    kergadic35

      Hi,

       

      I have created this little application :


      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:local="*">
         
          <mx:Script>
              <![CDATA[
                  import mx.controls.Alert;
                  [Bindable] public var test1Appli:String;
                 
                  public function init():void {
                      test1Appli = "<racine><item>123456</item></racine>"
                  }       
                 
                  public function alert():void {
                      Alert.show(test1Appli);
                  }
              ]]>
          </mx:Script>
         
          <mx:VBox>
              <mx:TextArea id="textarea" text="{test1Appli}"/>
              <mx:Button label="INIT" click="init()"/>
          </mx:VBox>
         
      </mx:Application>

       

      The button permits to update the "test1Appli" variable. With databinding, the textArea text is updated. If I modify the textarea manually, the databinding is "broken" (when I click on the button the textarea text doesn't change). So I have to put a 2-way binding (ie. <mx:Binding source="textarea.text" destination="test1Appli"/>) to have a normal situation. I am OK with that point.

       

      What I don't understand is if I modify the "test1Appli" type in XML, I have not to create a 2-way binding, a single one is only necessary. Why do I have this difference ?

       

      Regards