2 Replies Latest reply on Aug 31, 2009 9:42 PM by Shivik

    Best Practices for Remote Data Communication?


      Hello all


      I am developing a full-fledged website in Flex 3.4 and Zend Framework, PHP. I am using the Zend_AMF class in Zend framework for communicating the data to remote server.


      I will be communicating to database in the following way...

      • get data from server
      • send form data to server
      • send requests to server to get data in response


      Right now I have created just a simple login form which just sends two fields username and password in the method in service class on remote server.

      Here is a little peek into how I did that...


      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
        <mx:RemoteObject id="loginService" fault="faultHandler(event)" source="LoginService" destination="dest">
          <mx:method name="doLogin" result="resultHandler(event)" />
            import mx.rpc.events.ResultEvent;
            import mx.controls.Alert;
            private function resultHandler(event:ResultEvent):void
              Alert.show("Welcome " + txtUsername.text + "!!!");
        <!-- Login Panel -->
            <mx:Label text="LOGIN"/>
              <mx:Label text="Username"/>
              <mx:TextInput id="txtUsername"/>
              <mx:Label text="Password"/>
              <mx:TextInput id="txtPassword" displayAsPassword="true" width="100%"/>
            <mx:Button label="Login" id="loginButton" click="loginService.doLogin(txtUsername.text, txtPassword.text)"/>


      This works fine. But if I create a complicated form which has many fields then it would be almost unbearable to sent each fields as an argument of a function.


      Another method that can be used is using HttpService which supports XML like request and response.


      I want to ask what are best practices in Flex when using remote data communication on a large scale? Like may be using some classes or objects which store data? Can somebody guide me on how to approach data storing?


      Thanks and Regards