我在Windows上有游戏服务器,FMS 4.5,已经工作完美,客户端应用程序是在旧的CS4中创建的,一切都很完美。
现在我想在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
}
正如我所说,此代码正在使用旧的Flash软件,但在使用AS3时不会更新。有什么想法吗?
答案 0 :(得分: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());
}
}