2016-10-01 34 views
1

我有遊戲服務器,FMS 4.5在Windows上,已經工作知府,和客戶端應用程序在舊的CS4中創建,並且都是完美的。遠程共享對象沒有觸發onSync方法更新後

現在我想在AS3中創建一個移動應用程序,並且在遠程共享對象方面存在問題,這是在舊版Flash程序中完美工作的。

當用戶登錄到應用程序時,我收到了onSync方法的更新。但是,每當遠程共享對象更新時,我都沒有收到更新。

例如,在客戶端,在那裏我有main_nc爲NetConnection對象:

var ncu_so:SharedObject = SharedObject.getRemote("Zusers", main_nc.uri, false); 
ncu_so.addEventListener(SyncEvent.SYNC, syncNCU); 
ncu_so.client=this; 
ncu_so.connect(main_nc); 

private function syncNCU(e:SyncEvent):void { 
    ........ 
    //here I receive new info.... 
} 

和服務器樣本...

application.onAppStart = function(){ 
    this.Zusers_so = SharedObject.get("Zusers", false); 
    ........... 
} 
function sampleUserEnter(client) { 
    var t=new Object(); 
    t.username=client.username; 
    application.Zusers_so.setProperty(client.id,t); 
    //this one call is synced with app 
} 
function sampleChangeName(client,newName) { 
    var t=application.Zusers_so.getProperty(client.id); 
    t.username=newName; 
    application.Zusers_so.setProperty(client.id,t); 
    //this IS NOT syncing with app 
} 

正如我所說的,這個代碼正在與舊閃光燈軟件,但在使用AS3時不會更新。任何想法?

+0

「*該代碼使用AS3 *當老Flash軟件,但不會更新工作」這你CS4沒有使用AS3那麼這是怎麼了相同的代碼?你之前使用過什麼代碼?您正在將IDE名稱與語言名稱混合起來,這沒有多大意義。請澄清。 – null

+0

我很早以前就在flash CS4中用舊的as2編寫了代碼,它正在工作。現在我正在爲as3中的移動設備開發應用程序,並且不會更改Web服務器上的任何內容,因爲它實際上正在工作,但在AS3中,我介紹的刷新遠程共享對象有一些麻煩。 –

回答

1

我找到了一個簡單的解決方案。不知道爲什麼它的工作原理,但它的工作原理....

var ncu_so:SharedObject = SharedObject.getRemote("Zusers", main_nc.uri, false); 
ncu_so.addEventListener(SyncEvent.SYNC, syncNCU); 
//I add the listener for checking status 
ncu_so.addEventListener(NetStatusEvent.NET_STATUS, statusNCU); 
ncu_so.client=this; 
ncu_so.connect(main_nc); 

private function syncNCU(e:SyncEvent):void { 
    ........ 
    //here I receive new info.... 
} 
//In function for NetStatus event, I just set a simple property 
//which I do not use in the app.. 
//and sunchronization start working as usual after initial sync 
private function statusNCU(ev:NetStatusEvent):void { 
    if (ev.info.code == "NetConnection.Connect.Success") { 
     ncu_so.setProperty("anyPropertyName",new Date()); 
    } 
}