4 Replies Latest reply on Jun 2, 2006 9:32 AM by poonamsheth

    RemoteObjects

    Anurag Mishra
      I want to use RemoteObjects in Flex. Can I use PHP objects instead of Java objects?

      If I were to use Java objects with RemoteObject, do I necessarily need a server like Tomcat, JRun etc.. Or can I deploy the compiled .swf and java .class files in same directory and use RemoteObject functionality?
        • 1. Re: RemoteObjects
          ntsiii Level 3
          I am not sure but I believe Java is required for remoteObject. I did just read about WebOrb, who is creating a .NET framework that can communicate with Flex via RemoteObject.

          And yes, you will need Tomcat or other servlet container. Flex 2 does not require a server, but Flex 1.5 did.

          Tracy
          • 2. Re: RemoteObjects
            poonamsheth Level 1
            Flex and PHP - A simple sample

            a small Flex Builder 2.0 sample that uses PHP to update a MySQL database, with the front end being a Flex based application. In this very simple example, we have two fields, username and email address, and a datagrid. The username and email address fields are text fields, and filling them in and clicking on the "Submit" button adds them to the database. The data grid displays all the users, with an ID and their username. Below that, a text field shows the email address of the selected user

            MySQL schema:
            Note: The PHP code assumes that you have created the following table in a database called "sample":
            CREATE TABLE `users` (
            `userid` int(10) unsigned NOT NULL auto_increment,
            `username` varchar(255) collate latin1_general_ci NOT NULL,
            `emailaddress` varchar(255) collate latin1_general_ci NOT NULL,
            PRIMARY KEY (`userid`)
            ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=3 ;

            MXML:
            <?xml version="1.0" encoding="utf-8"?>
            <mx:Application xmlns:mx=" http://www.macromedia.com/2005/mxml" xmlns="*" layout="absolute" creationComplete="send_data()">
            <mx:Script>
            <![CDATA[
            private function send_data():void {
            userRequest.send();
            }
            ]]>
            </mx:Script>
            <mx:Form x="22" y="10" width="493">
            <mx:HBox>
            <mx:Label text="Username"/>
            <mx:TextInput id="username"/>
            </mx:HBox>
            <mx:HBox>
            <mx:Label text="Email Address"/>
            <mx:TextInput id="emailaddress"/>
            </mx:HBox>
            <mx:Button label="Submit" click="send_data()"/>
            </mx:Form>
            <mx ataGrid id="dgUserRequest" x="22" y="128" dataProvider="{userRequest.result.users.user}">
            <mx:columns>
            <mx ataGridColumn headerText="User ID" columnName="userid"/>
            <mx ataGridColumn headerText="User Name" columnName="username"/>
            </mx:columns>
            </mx ataGrid>
            <mx:TextInput x="22" y="292" id="selectedemailaddress" text="{dgUserRequest.selectedItem.emailaddress}"/>
            <mx:HTTPService id="userRequest" url=" http://localhost/flex/php/request.php" useProxy="false" method="POST">
            <mx:request xmlns="">
            <username>{username.text}</username><emailaddress>{emailaddress.text}</emailaddress>
            </mx:request>
            </mx:HTTPService>
            </mx:Application>

            request.php:
            NOTE: You'll likely have to change the default "username" and "password".

            <?php
            //connect to the database
            $mysql = mysql_connect(localhost, "username", "password");

            mysql_select_db( "sample" );
            //if the username and email address are filled out
            if( $_POST["emailaddress"] AND $_POST["username"])
            {
            //add the user
            $Query = "INSERT INTO users VALUES ('', '".$_POST['username']."', '".$_POST['emailaddress']."')";

            $Result = mysql_query( $Query );
            }

            //return a list of all the users
            $Query = "SELECT * from users";
            $Result = mysql_query( $Query );

            $Return = "<users>";

            while ( $User = mysql_fetch_object( $Result ) )
            {
            $Return .= "<user><userid>".$User->userid."</userid><username>".$User->username."</username><emailad dress>".$User->emailaddress."</emailaddress></user>";
            }
            $Return .= "</users>";
            mysql_free_result( $Result );
            print ($Return)
            ?>

            Link::

            http://blogs.adobe.com/mikepotter/2006/02/flex_and_php_a_1.html


            • 3. Re: RemoteObjects
              Anurag Mishra Level 1
              Thanks for your help. I got flex working with php and java.

              Cheers
              • 4. Re: RemoteObjects
                poonamsheth Level 1
                well here is my blog which is under construction yet...

                Flex developers might get some of thier answers here..

                The intention is to be a FAQ/knowledgebase for Flex2b3 users. Since I noticed that a lot of similar questions are being repeated on the forums, this should solve a lot of problems. I shall be picking up any interesting topics that occur on the forums and their solutions here. Happy FlexDevelopers!

                http://smspoonam.blogspot.com/