I was wondering if it is possible to connect to the the services/amfphp gateway via flash.net.NetConnection. I'm working with AS3 in Flex, but I would like to be able to connect to amfphp without implementing the RPC framework. I have completed the Flex tutorials that use mx.rpc.remoting.RemoteObject so I know that everything is configured correctly. I have successfully connect to the amfphp gateway using gateway.connect("http://localhost/amfphp/gateway.php"); with the following example, but when I change the address to http://localhost/services/amfphp/gateway.php nothing is returned.
I know that the AMFPHP Module overrides some aspects of amfphp, but I'm new to php, and I don't exatly understand the interaction (what is sent to Flex/Flash via services/amfphp and how to call the php Methods).
My ultimate goal is not to work with php files in the amfphp/service folder, but rather with drupal services i.e. node views. I would just like to streamline the actionscript code.
Any and all help will be greatly appreciated.
Thanks,
Kyle
The following example class works with "localhost/amfphp/gateway.php" but not with "localhost/services/amfphp/gateway.php"
Also, I've attempts to call node one using "gateway.call("node.load(1)," are ineffective, am I missing something basic in the method call?
package {
import flash.display.Sprite;
import flash.net.NetConnection;
import flash.net.Responder;
public class AS3Example extends Sprite {
public var gateway:NetConnection;
public function AS3Example() {
gateway = new NetConnection();
gateway.connect("http://localhost/services/amfphp/gateway.php");
gateway.call("HelloWorld.say", new Responder(onResult, onFault), "say this" );
}
public function onResult(responds:Object):void {
trace ("onResult: " + responds)
}
public function onFault(responds:Object):void {
trace("fault " + responds);
}
}
}
Comments
Comment #1
JoachimVdH commentedherewith a little sample. This works for me.
Comment #2
Patrick Daulie commentedGreat ! This is the first example that really worked for me. This explains a lot ! Thank you for this.
Do you also have an example how to read only the title and the body with the html tags stripped ?
This is my result in my swf file:
Comment #3
yoda-fr commentedHey eldude,
thanks for your exemple, it's very interesting.
It works well for node but I have trouble to display views. When I do
gateway.call("views.get", responder, "pages");
it shows me
onResult: undefined
0: [object Object]
1: [object Object]
2: [object Object]
I tried some things without success.
Can you help me, I am new to as3 and amfphp
Thanks a lot for your help