【发布时间】:2013-05-09 21:51:36
【问题描述】:
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");
【问题讨论】:
-
您能否提供一个链接到您从中获取此代码的页面?
-
另外,您应该仅在连接到服务器后才连接共享对象
标签: actionscript-3 shared-objects