- Starting with AMFPHP From Flex Cookbook online
- Flex and PHP: remoting with AMFPHP
- Flex RemoteObject and AMFPHP 1.
Then download StartingWithAMFPHP1.zip Use SQL script to generate tables in MySQL database. Extract all from PHP directory into AMFPHP service directory. In FLEX directory you can find a finished Flex project that you can import into your Flex workspace.
2. Create database
3. Create PHP files
~/Sites/en.h.com/amfphp/services/org/zgflex/cookbook/services/SoccerManager.php
data objects
~/Sites/en.h.com/amfphp/services/org/zgflex/cookbook/dao/Player.php
~/Sites/en.h.com/amfphp/services/org/zgflex/cookbook/dao/Team.php
Please note, PHP script must have the same name as the class inside of it.
4. Create Flex project
MXML application uses two remote objects, one is calling dummy PHP service and the other one works with the soccer data and helps you handle the data.
StartingWithAMFPHP.mxml
......
fault="faultHandler(event)" showBusyCursor="true">
<mx:method name="communicationTest" result="checkCommunicationHandler(event)" />
<mx:method name="checkAnotherMethod" result="checkCommunicationHandler(event)" />
</mx:RemoteObject>
<mx:RemoteObject id="SoccerService" source="org.zgflex.cookbook.services.SoccerManager" destination="amfphp"
fault="faultHandler(event)" showBusyCursor="true">
<mx:method name="getTeams" result="getTeamsHandler(event)" fault="faultHandler(event)" />
<mx:method name="updateTeam" result="updatedTeamHandler(event)" fault="faultHandler(event)" />
</mx:RemoteObject>
......
Just as you created PHP data class in Team.php, you need to create a simple mapping class in Actionscript. In this class you will store all the data and use it for handling data changes and sending the data back to the server. See Player.as and Team.as in Flex project folder: src/org/zgflex
You also need to configure services-config.xml file, and edit your URL to the AMFPHP gateway.php script.You have to use this XML file while the Flex project is compiled. You will do this by adding compiler parameter in project properties. Your compiler propetries should look something like this:
-locale en_US -services "services-config.xml"
Export the release build to bin-release folder and upload it to webserver's folder: ~/html/Sites/en.h.com/StartingWithAMFPHP/, and now you can access it at: http://en.hycademy.com/StartingWithAMFPHP/StartingWithAMFPHP.html
No comments:
Post a Comment