2 Replies Latest reply on Aug 28, 2006 10:27 AM by ntsiii

    Data binding not working as expected

    renspr
      Hi,

      I just startet with flex 2 and have some problems with data bindings. I have the following simple application which consists of an ActionScript class and an mxml file.

      === ActionScript class ===
      package com.openep.core.data
      {
      [Bindable]
      public class Account
      {
      public var identifier:String = "FOO";
      }
      }
      === ActionScript class end ===

      === MXML File ===
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute">

      <mx:Script>
      <![CDATA[
      import mx.controls.Alert;
      import com.openep.core.data.*;

      [Bindable]
      public var account:Account = new Account();

      private function doSomething():void {
      Alert.show(account.identifier);
      }
      ]]>
      </mx:Script>

      <mx:TextInput x="10" y="10" text="{account.identifier}"/>
      <mx:Button x="178" y="10" label="Button" click="doSomething()"/>

      </mx:Application>
      === MXML File end ===

      If I run this application the TextInput will show the text "FOO" as expected. But when I change this text and hit the Button (which calls the doSomething() method) the text in the AlertBox is still "FOO". I expect the text would reflect my change in the text input.

      So why does the binding only works in the read direction and changes to the text input are not reflected in the account object? I tought that this would work, but mayby I missed something.

      Hope that anyone can give my a hint.

      Best regards, René