AMFPHP: Flash - PHP interaction  Hot PDF Print E-mail
Tag it:
Delicious
Furl it!
Digg
NewsVine
Reddit
YahooMyWeb
Technorati
Articles Reviews Actionscript
Written by Tibor Gyorgy Ballai   
Thursday, 29 March 2007

Any Flash developer who has worked on RIAs (Rich Internet Applications) that needed to interact with PHP knows that this isn’t a simple process at all. Although AMFPHP has been around for quite a while, I will start with a simple introduction and then build from there in coming articles.



Before AMFPHP was available the only two options to send and load data from PHP were LoadVars and XML. If you wanted to query a database and return a complex data structure then your best option would have been XML since it was more suitable for structuring the data.

But even with XML in order to retrieve data from a database you needed the logic that would do the actual query then additional logic that would parse the results of the query and build the xml string and finally parsing the xml on the client side in ActionScript to retrieve the data from the XML object.

You may ask: "So, what’s wrong with that?".

In a complex application debugging and maintenance will become pretty difficult if you have hundreds of PHP scripts just for the sole purpose of generating the xml strings, and several scripts on the client side to parse those xml objects and retrieve the necessary data. Not to mention the waste of time and resources needed to build something on the server side that you will automatically deconstruct on the client side.

Why is AMFPHP better?

Imagine writing a function on the server that queries the database and returns an array i.e.

 return mysql_fetch_array(mysql_query("select * from table LIMIT 1"));

Then simply calling that function from ActionScript and getting an array with the results. No need to build XML strings on the server, no need to decode/parse data on the client side. If you send a number you will receive a number, if you send a string you will receive a string, if you send an array you will receive an array, even array keys are preserved.

The data transfer is done in the binary AMF format rather then text format. The gateway and the ActionScript classes translate the data into this neutral format, thus allowing language specific data to be exchanged transparently.
If you would like to know more about how AMFPHP works you can check out their official website at http://www.amfphp.org/

Hello World!

Let's get started by setting up a classic "Hello World!" example:

First of all in order to use AMFPHP you will need to install the Adobe Remoting components for Action Script 2. You can download them from: http://www.adobe.com/products/flashremoting/downloads/components/

After installing the remoting components you will need to install AMFPHP. You can download the latest version from: http://www.amfphp.org/

In order to install AMFPHP you will need a web server with PHP installed. You can choose between Apache, IIS, or other web servers. For the sake of simplicity I will assume that you are a Windows XP user and will install IIS.

Installing IIS on Windows XP:

Open your Control Panel:

Click on "Add or Remove Programs";

Click on "Add/Remove Windows Components";

Check the box beside "Internet Information Services (IIS)"

Read more


User reviews

There are no user reviews for this item.

Add new review




Powered by jReviews

Last Updated ( Thursday, 03 January 2008 )
 
< Prev   Next >