Apache flex flex netconnect(在flash.net.NetConnection上找不到属性onTest,并且没有默认值)

Apache flex flex netconnect(在flash.net.NetConnection上找不到属性onTest,并且没有默认值),apache-flex,actionscript,Apache Flex,Actionscript,有此代码: nc.call("test", new Responder(onCallSuccess,onCallFailed), "user1"); 及 结果: `ReferenceError: Error #1069: Property onTest not found on flash.net.NetConnection and there is no default value`. 我怎样才能解决这个问题? 我尝试了很多不同的方法,似乎数据是从服务器应用

有此代码:

nc.call("test", new Responder(onCallSuccess,onCallFailed), "user1");                

结果:

`ReferenceError: Error #1069: Property onTest not found on flash.net.NetConnection and there is no default value`.
我怎样才能解决这个问题?
我尝试了很多不同的方法,似乎数据是从服务器应用程序正确发送的,但flex不能“吃掉它”

据我所知,
onTest
是回调方法。回调方法必须包含在
NetConnection
实例的
client
属性中。客户端的默认值是
NetConnection
instance itselft。这就是为什么
onTest
试图被调用,但它不存在。这里有两种可能的解决方案:

1.使用自定义类扩展NetConnection类,并在其中定义
onTest
方法。并改用自定义类

class MyNC extends NetConnection
{
     public function onTest(id:String) {...}
     ...
}
2.创建类,它将是NetConnection的客户端,并在那里定义
onTest

class Client
{
    public function onTest(id:String) {...}
}
...
var nc:NetConnection = new NetConnection();
nc.client = new Client();

您需要添加
nc.client=this
,以便服务器知道在哪里调用方法

class Client
{
    public function onTest(id:String) {...}
}
...
var nc:NetConnection = new NetConnection();
nc.client = new Client();