2 Replies Latest reply on Oct 14, 2010 2:20 AM by RenanCunhaa

    [Problem] Get data from Data/Services (MySQL + Zend AMF PHP)




      Im using Zend AMF PHP in Flash Builder 4 to access a MySQL database.

      I have some methods in php generated automatically by Zend AMF.

      My methods is to manipulate a table of Accounts.

      Have method to get all accounts etc...


      I can put the data of method getAllAccounts in a datagrid.


      But, Im making a login system, and I have a method with a parameter: getAccountByName($name)

      I need to know, how I can put this method inside the AC code for example...

      I need to know if already exists a account with "X" name, and for this, I need to execute getAccountByName.


      Someone help-me?






        • 1. Re: [Problem] Get data from Data/Services (MySQL + Zend AMF PHP)
          mike_morales Level 2

          I'm not sure if you are using FB4's built-in tools for hooking up your services or writing your actionscript by hand, but one approach is to use a RemoteObject and a CallResponder.  (If you are using the built-in tools, you can probably tap into the existing remote object that was generated by FB and just create a new CallResponder).

          If you are hand-coding, it would be something like:


          var tempRemoteObject:RemoteObject = new RemoteObject();

          tempRemoteObject.source("THE NAME OF YOUR PHP SERVICE");

          // i'm assuming you already have your services xml config file set up


          var tempCallResponder:CallResponder = new CallResponder();



          // next call your php method through your remote object and assign it to your call responder

          tempCallResponder.token = tempRemoteObject.getAccountByName("X");


          private function allAccountsLoaded(event:ResultEvent):void{

               // your returned data here through 'event.result';



          so, for example, if you had a user login text input components named "userLoginTxt", and "passwordTxt" with a button to 'login' it would be something like:


          private function login():void{

               tempCallResponder.token = tempRemoteObject.getAccountByName(userLoginTxt.text, passwordTxt.text);



          that would call your php method and sending your two parameters (userLogin, and password) which of course executes the query on the database and returns a result.


          There's likely an easier way to do this through FB's built-in tools, but I typically hand-code a lot of stuff.  Anyways, that is one way of calling/sending data to your service.

          • 2. Re: [Problem] Get data from Data/Services (MySQL + Zend AMF PHP)
            RenanCunhaa Level 1

            But if getAccountByName, return an Account object.

            How I get the result of this method?


            Its my doubt...

            Very thanks man!