In the next phase, we modify the
ContactManager to replace the XML file with an
HTTPService call to a PHP script that will request every contact record in a MySQL database and return it in XML format. We also use an
HTTPService class to call PHP scripts that will either insert new contact records into the database or update existing contact records.
As it happens, there are two separate classes for the
HTTPService component, one designed for use as an MXML component (
mx.rpc.http.mxml.HTTPService), and the other designed for use in ActionScript (
mx.rpc.http.HTTPService). Of course, we will show you both.
We’re ready to integrate the first PHP script, but first we have to create it. Start by using whatever method you prefer to add a php folder under the project’s src directory. Next, select the new php directory, open the File menu, and chose New→File. In the dialog, provide the filename loadContacts.php; be sure to include the file extension.