O'Reilly logo

Learning Flex 4 by Elijah Robison, Alaric Cole

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Linking ContactManager to the Server Using the HTTPService Class

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.

Loading Contacts Using the HTTPService Component

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.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required