I've recently set up amfphp 2.2.1 on my win7pro (iis7.x) local host in the hope of getting away from XML between phph and Flash. I Followed the inital 'hello world' tut on amfphp website and everything was great.. it worked. My problem started when I tried querying a mySQL db. my debug proxy says there is data being grabbed via amfphp/index.php (getAvailSvc/getBds) and it appears to be the data that I expected. When I try to view that data in Flash. When I try the simplest of functions
function handleResult(respond:Object):void{
trace(respond);
}
the trace give me [object Object],[object Object],[object Object]... etc
When I edit the trace to (respond.serverInfo.initialData) or my function to read the objects thus:
function handleResult(respond:Object):void{
var h:Array = respond.serverInfo.initialData;
for (var i:uint = 0; i < h.length; i++){
trace (h[i][0]);
}
}
I get the following error:
TypeError: Error #1010: A term is undefined and has no properties. at amf_fla::MainTimeline/handleResult()
I've searched and searched the web for amfphp tuts and guidance but most, if not all, the stuff I found is circa 6-7 years old and relates only to mysql_query stuff and amfphp 1.9-. If anyone can help I'd appreciate your support and aplogise in advance if its me just being stupid.
@Ariel Sommeria-Klein - raised here as suggested
You get [object Object],[object Object],[object Object], because you are receiving an array of objects. In your AMF object, that would be "Content". So if you try the following in your handleResult function:
trace(respond[0]);
you should see simply [object Object]
and if you try the following:
trace(respond[0].name);
you should see Abbeydale Independent