Archive

Posts Tagged ‘ActionScript’

PHP Data Sources with Flex/ActionScript

March 7th, 2007

For Adobe Flex and ActionScript coders, communication with PHP data sources can be an absolute pain. There are no direct methods for communication, which usually leads to developing two completely different systems: a PHP system which writes data to an external file (XML, HTML, or text) and another Flex/AS3 system for interacting with the external file.

Luckily for these developers however, there is a toolkit designed to ease the burden of PHP data sources within Flex/AS3. AMFPHP, originally designed by Wolfgang Hamann, is an RPC toolkit PHP, allowing seamless communication between PHP and Flash/Flex/ActionScript, Javascript and AJAX, and XML with XML-RPC. More information directly from the site:

RPC (Remote Procedure Call) is a way to communicate data between a client and a server. You call a method on a local object with various parameters, set a callback, and receive a result. You don’t have to worry about how you’re going to send and receive the data. The server and the client, say php and Flash, agree on a common way of describing method calls and complex data. The implementation details are abstracted away so that it looks as though you’re calling a local method.

Amfphp lets you focus on features instead of implementation details. Testing remote services can be tricky, so amfphp has a built-in service browser which lets you test your services before you start writing the front end, and allows you to generate code for various clients. You can check it out here.

AMFPHP was designed with a few simple goals in mind:

  • Nothing required – PHP4/PHP5 compatible, no extensions needed
  • Low footprint, lightweight, fast
  • Convention over configuration (service and class mapping)
  • Can be embedded into a framework (see CakeAmfphp, Seagull)
  • Services are “non-specific” PHP classes that are portable to anything without code change
  • Productivity tools included (service browser, code gen, profiling)
  • Batteries included – XML-RPC, JSON
  • Not a framework by itself (use your own)

I live by AMFPHP when developing with Flex and Actionscript. Another priceless development tool which you will come to treasure if you give it a chance. As always, you can find more information as well as download information from the AMFPHP Homepage