Skip to content

Connecting to an AMF3 backend with AMFPHP and Flex

December 7, 2009
Ever tried populating a Datagrid with about 4000 rows of complex objects (10 key/values each).
Thats a lot to convert from XML to Actionscript Objects; Even yet, you shouldn’t blame your browser if it crashes.
James Ward has given a perfect example of the speed differences between XML, JSON and AMF.
It’s pretty and easy to connect to an AMFPHP back end. The advantages of this are many, one of them is the size of the data itself, AMF sends ByteArray data, plus, there is no need to convert XML nodes into Objects, AMFPHP hands them to you as objects!

private var _gatewaySitesDD:NetConnection = new NetConnection();                   // create a NetConnection
private var _responser:Responder = new Responder(onResultSitesCB, onFault);        // create a responder for the NetConnection
_gatewaySitesDD.connect(""); // php gateway URL"AMF3Query.query", _responser, "name=lookup_sites");          //, responder:Responder, ... arguments)

private function onResultSitesCB(response:Object):void {
   trace ("Result received");
   siteData = response as Array;  // See that! Returns them as Array, as in Array of Objects!

private function onFault(response:Object):void {
   trace ("Error receiving data);


From → AIR, Uncategorized

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: