Actionscript 3 从flash media server调用响应程序类
我有一个问题需要在flash媒体服务器中定义的异步函数中调用flash客户端中定义的responder方法 我的客户代码 专用功能手柄 (结果:Object){trace(“获取 数字“+结果.数字);} netConnection.call(“getnum”,新建) 响应者(handleResp) 我的服务器代码 Application.handleServerResp.onResult =函数(结果) { /???如何调用客户端的handleResp } > Client.prototype.getnum=函数() { //找不到号码,请另拨一个 服务器(中央一台)的号码 centralNetConnection.call (“getnumNOW”,新响应者 (handleServerResp));}Actionscript 3 从flash media server调用响应程序类,actionscript-3,Actionscript 3,我有一个问题需要在flash媒体服务器中定义的异步函数中调用flash客户端中定义的responder方法 我的客户代码 专用功能手柄 (结果:Object){trace(“获取 数字“+结果.数字);} netConnection.call(“getnum”,新建) 响应者(handleResp) 我的服务器代码 Application.handleServerResp.onResult =函数(结果) { /???如何调用客户端的handleResp } > Client.prototype
基本上,Responder类用于处理服务器方法的返回值,因此不能异步使用它。 您可以这样做: 创建一个客户端响应程序方法(它应该是公共的,否则FMS无法访问它) 设置NetConnection对象的客户端
netConnection.client = this; // if your responder function is in this scope, otherwise set that object what contains your function.
调用服务器端方法
netConnection.call ("getnum", null); // set null as resopnder
Application.handleServerResp.onResult = function (result)
{
clientOBJ.call( "handleResp", null, result ); // you don't use responder, so pass null as second parameter
}
在服务器端的响应程序方法中,调用客户端方法
netConnection.call ("getnum", null); // set null as resopnder
Application.handleServerResp.onResult = function (result)
{
clientOBJ.call( "handleResp", null, result ); // you don't use responder, so pass null as second parameter
}
希望这有帮助
干杯
塔马斯·格罗纳斯@塔马斯,这正是我所做的。谢谢你的回复。