Preparation:
1, as3 xmlRPC
Download link: http://danielmclaren.net/2007/08/03/xmlrpc-for-actionscript-30-free-library
2, php xmlRPC
This article uses the php that comes xmlRPC, of course you can also use the XML RPC for PHP writed by the other people, both use similar, but for the second, said memory management is better.
Download link: http://phpxmlrpc.sourceforge.net/
Operating System: Windows
AS3 Project:
1, after extracting as3xmlrpc, put the com folder to src directory, and then
package {
//import xmlrpc
import com.mattism.http.xmlrpc.*;
import com.mattism.http.xmlrpc.util.*;
import flash.display.Sprite;
import flash.events.ErrorEvent;
import flash.events.Event;
public class Client extends Sprite
{
private var rpc:Connection;
public function Client()
{
rpc = new ConnectionImpl(“http://127.0.0.1/xmlrpc.php”);
// Listening back to results
rpc.addEventListener(Event.COMPLETE,__onComplete);
rpc.addEventListener(ErrorEvent.error,__onError);
// Need to pass parameters to the server in this form
rpc.addParam(“is”, XMLRPCDataTypes.STRING);
rpc.addParam(“ok”, XMLRPCDataTypes.STRING);
// Need to register at the server side to achieve rpc_server
rpc.call(“rpc_server”);
}
public function __onComplete(e:Event):void{
var tr:Object = rpc.getResponse();
trace(tr);
}
public function __onError(e:Event):void{
var te:MethodFault = rpc.getFault();
trace(te);
}
}
}
PHP side: xmlrpc.php
<?php
/. / **
* Function: to provide the function to the RPC client calls
* Parameters:
* $ Method the function which the client needs to call
* $ Params the parameter array which client needs to call the function
* Return: Returns the result is called
*/
function rpc_server_func($method, $params) {
$return = ”method:”.$method.”\nparams[0]:”.$params[0].”\nparams[1]:”.$params[1];
return $return;
}
// Create a server-side XML-RPC
$xmlrpc_server = xmlrpc_server_create();
// Register a server-side method call rpc_server, the actual point is rpc_server_func function
xmlrpc_server_register_method($xmlrpc_server, ”rpc_server”, ”rpc_server_func”);
// accept the POST XML data from the client’s
$request = $HTTP_RAW_POST_DATA;
// Implementation of the calling client XML request, to obtain performance results
$xmlrpc_response = xmlrpc_server_call_method($xmlrpc_server, $request, null);
// output XML
header(‘Content-Type: text/xml’);
echo $xmlrpc_response;
// Destruction of XML-RPC server-side resources
xmlrpc_server_destroy($xmlrpc_server);
?>
View results returned. In the debugging process may encounter security sandbox issue. We can try add “-use-network = false” into the property “As Additional Compiler arguments”. Problems generally can be resolved.
Your blog provides us a very great information. Its really very helpful to me to find result on search engine. Hope to hear more good information related to searching from your side.
This is the good step u have taken. Thanks for writing this, its clear you have spent a good amount of time on your sites development.
Absolutely insightful article, I was glad to uncover your web sites over the internet. I put a web page link on my own blog website thus my site visitors could possibly reach a site. Please consider a look.
golf club set…
After study a few with the weblog posts on your web site now, and I truly like your way of blogging. I bookmarked it to my bookmark web site list and will be checking back soon. Pls check out my web site also and allow me to understand what you believe…
barbie doll sportster car…
I found your blog site on google and verify a few of your early posts. Continue to maintain up the very good function. I just additional up your RSS feed to my MSN News Reader. Seeking ahead to reading much more from you later on!…
Beta invites…
[..] free beta invites for all of your favorite communities, programs, games etc. [..]…
Links…
[...]Sites of interest we have a link to[...]……