Adobe 文档中似乎有关于使用共享object.send()
. 我正在尝试对所有客户端执行发送方法。
我从 Adobe 复制了客户端和服务器端代码,但无法调用该函数。这是我在输出中的编译错误
Line 31 1119: Access of possibly undefined property doSomething through a reference with static type flash.net:SharedObject.
任何建议我如何解决这个问题给 as3 新手。请问有人可以帮我吗?
var nc:NetConnection = new NetConnection();
nc.connect("rtmfp://localhost/submitSend");
nc.addEventListener(NetStatusEvent.NET_STATUS, netHandler);
function netHandler(event:NetStatusEvent):void{
switch(event.info.code){
case "NetConnection.Connect.Sucess":
trace("Connecting...");
break;
case "NetConnection.Connect.Failed":
trace("Unable to connect up");
break;
case "NetConnection.Connect.Rejected":
trace("Whoops");
break;
}
}
var so:SharedObject = SharedObject.getRemote("mySo", nc.uri, true);
so.connect(nc);
so.doSomething = function(str) {
// Process the str object.
};
服务器端:
var so = SharedObject.get("mySo", true);
so.send("doSomething", "This is a test");