Flash / ActionScript + AMF + Zend Framework mini-How-To

There are times when you need your Flash applet to fetch data from an external source. The simplest way to do that with a PHP backend is a combination of Zend Framework’s AMF module and Flash’s built in AMF remoting feature (Action Message Format).

The steps to go about doing that is to have the client side flash component, and a server side PHP component with Zend Framework installed.
On the flash side, you create a netconnection object, assign the gateway as the URI of your web service (http://example.com/services/amf.php in this case). You specify a responder and set it to listen to any events. In the example below, I use JSON to encode the objects, but that’s optional, I just happened to be dealing with JSON objects at the time.

Source example follows:
Continue reading