Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
Locked
0

onSync Handler

New Here ,
Apr 18, 2006 Apr 18, 2006
Hi, Im learning flash media server at the mo and have a problem. I'm trying to use an onsync handler so that when a player clicks a movieclip on stage and moves it, the same movieclip moves on all other clients.

The way i am trying to initiate this is as follows,

//>> First i've set a remote sharede objects data to be updated.
///tank_coord_so.data[tName]={sx : x,sy : z,destx : x,desty : dy};

I've just got 4 variables, start x & y and destination x & y


//>> The onSync handler does work but it does not move the movieclip on any of the other clients, only the client who moved the movieclip;

///tank_coord_so.onSync = function(list) {

for(i in tank_coord_so.data){

var pos=tank_array_info_so.data[ i ]; //finds the position in local array that contains tank object

trace("onsync pos"+pos);

var x=tank_coord_so.data .sx;

var y=tank_coord_so.data
.sy;

var destx=tank_coord_so.data .destx;

var desty=tank_coord_so.data
.desty;

var obj : Object=_root.tanks[pos];
obj.clip._x=destx;
obj.clip._x=desty;

So the onSync works but only moves the movieclip on one client (the client who selected it to move);

Any advice or insight would be appreciated a lot.

Thanks,
B.
243
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 18, 2006 Apr 18, 2006
LATEST
You need to make sure that the sharedObject is synced AND connected first before everything works properly. I'm betting that it hasn't had the connect method called.

//--------
//CODE (why I don't have the "add code to message" option available is beyond me)
//---------

var sharedObjectSynced:Boolean = false;

var NC:NetConnection = new NetConnection()
NC.connect("rtmp://myServer.myDomain.com")

var my_so:SharedObject = SharedObject.getRemote("positionData",NC.uri,true)

my_so.onSync = function(info){
if(!sharedObjectSynced){
sharedObjectSynced = true;
trace("Shared Object ready for use.")
}else{
//code to update tank positions using sharedObject data

}
}
my_so.connect(NC)


Cheers,
FlashTastic






Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines