PHP服务端Catalog类实现与远程方法定义
PHP服务端代码实现如下:
具体代码展示如下:
/* /flashservices/services/Catalog.php */
class Catalog {
var $products_array = array();
// 构造函数:包含对网管可用的方法列表
function Catalog() {
$this->methodTable = array ("getProducts" => array (
"description" => "Get list of products",
"access" => "remote",
"arguments" => "" // 参数可选,未测试
)); // end methodTable
}
function getProducts() {
// 在此处编写你的业务逻辑代码
return $this->products_array;
}
}ActionScript客户端代码实现如下:
具体代码展示如下:
#include "NetServices.as"
NetServices.setDefaultGatewayUrl("http://yourserver.com/flashservices/gateway.php");
gw = NetServices.createGatewayConnection();
CatalogREMOTE = gw.getService("Catalog", this);
CatalogREMOTE.getProducts();
getProducts_Result = function(result) {
_root.products_results = result;
}