2 Replies Latest reply on Jan 22, 2007 6:23 AM by witt1

    Help on flex data binding

      I've been having difficulties getting data binding to work. In a nutshell, my application should:

      1. Allow the user to log in. This process (an HTTPService) returns a user id.
      2. Store the user id in a local client-side object
      3. Bind that userid property to an HTTPService <mx:request> parameter which will be used to retrieve data specific to that user.

      Some code:
      MXML - performs login and defines the HTTPService
      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" xmlns="*" layout="absolute">

      <mx:Script source="test.as"/>

      <mx:HTTPService id="clientRequest"
      url=" http://localhost/flextest/getClients.php" useProxy="false" method="POST">
      <mx:request xmlns="">

      <mx:Form x="22" y="10" width="493">
      <mx:Label text="Username"/>
      <mx:TextInput id="username"/>
      <mx:Label text="Password"/>
      <mx:TextInput id="password"/>
      <mx:Button label="Submit" click="performLogin();"/>
      <mx:Label id="loginresult" text="Not Logged In"/>

      UserData.as - the object that contains the userid
      package {

      public class UserData {

      public var username:String;

      public var id:Number;
      public var name:String;


      test.as - contains the code that responds to the login event - this would eventually be an httpservice call, but simplified
      here to just set the user id as if it had been returned from the httpservice
      public var currentUser:UserData = new UserData();

      public function performLogin():void {
      clientRequest.send(); //executes the request to get additional user-specific data based on userid set above

      Note that UserData.id is marked [bindable]. According to the flex documentation, "Flex automatically dispatches an event named propertyChange when the property changes to trigger the data binding" when a public property is marked [bindable].

      I'm getting the warning, "Data binding will not be able to detect assignments to "currentUser" and "id" (two separate warnings).

      I've read much about databinding, but I'm not getting this. Any help is greatly appreciated.

      Witt Text