在使用共享object.send()
的Adobe文檔中似乎存在錯誤。我正在嘗試執行所有客戶端的發送方法。共享對象發送方法()
我從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");
你能提供一個鏈接到你把這個代碼的頁面? – duTr 2013-05-10 00:31:28
此外,只有在連接到服務器後,才應連接共享對象 – duTr 2013-05-10 00:32:10