Something wrong with my sync function. Help please.
Basically I want 3 users to connect up to the application to start the game. When the game starts...it displays a "Game has started" message on the clients' screens. I used shared object for this. However when i ctrl-enter the fla file...it says:
TypeError: Error #2007: Parameter text must be non-null.
at flash.text::TextField/set text()
at chemion_cs3_fla::MainTimeline/syncSO()
I dont know what it means. How to solve this problem? These are my codes:
=====================================================
Client side
=====================================================
var nc:NetConnection = new NetConnection();
nc.addEventListener(NetStatusEvent.NET_STATUS, onstatus1);
nc.connect("rtmp://localhost/myapplication2");
var txt1:SharedObject;
function onstatus1 (event:NetStatusEvent): void
{
switch (event.info.code)
{
case "NetConnection.Connect.Success":
trace("Congratulations! you're connected");
nc.client = this;
txt1 = SharedObject.getRemote("GameStartText", nc.uri, false);
txt1.connect(nc);
txt1.addEventListener(SyncEvent.SYNC, syncSO);
break;
case "NetConnection.Connect.Failed":
... ...
}
}
function syncSO(event:SyncEvent):void{
gameStart_txt.text = txt1.data.msg;
}
function StartGamee():void{
txt1.setProperty("msg", "Game has started");
}
... ...
====================================================
Server side
====================================================
application.allowDebug = true;
application.onAppStart = function(){
this.userID = 0;
}
application.onConnect = function(clientObj){
application.acceptConnection(clientObj);
clientObj._uniqueUserID = this.userID;
this.userID++;
if(this.userID == 3){
clientObj.call("startGamee", null);
}
}
application.onDisconnect = function(clientObj){
...
}
