Ask a Question related to Macromedia Flash Flashcom, Design and Development.
-
d00mc0ck #1
onSync Handler
Hi all,
I've got a problem with an onSync handler, hopefully someone can help.
In my client when a button is presseda function is called on the server>>>>
////////////////////////////////////////////////////////////////////////////////
/
newClient.msgFromClient = function() {
var x = newClient.id;
//trace("newClient.id :"+x);
//trace("in function");
application.tanks_so.send("msgFromSrvr", x);
};
////////////////////////////////////////////////////////////////////////////////
//////////////////
The above code sends the client id to a function on the client >>>>
////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////
_root.tanks_so.msgFromSrvr = function(x) {
var num = x;
var user = _root.users_so.data.user;
_root.client_nc.call("sendNameToServer", null, user);
}
////////////////////////////////////////////////////////////////////////////
The above function gets the users name & sends it back to a function on the
server.
This is where the problem is. >>>
////////////////////////////////////////////////////////////////////////////////
/////////////////
newClient.sendNameToServer = function(user) {
var uName = user;
var thisTankName = (p+"_"+"tank"+"_"+newClient.tankId);
application.tanksToBeBuilt_so.setProperty(newClien t.tankId,{ownedBy:uName,name
:thisTankName});
newClient.tankId++;
};
///////////////////////////////////////////////
The above function is supposed to make a new entry in the "tanksToBeBuilt_so"
RSO with the user who called it and the tank name as parameters.
I've tested the function with a trace statement and the function is
deffinately being entered.
It seems however that the RSO is not being updated and I cant figure out why?
My onSync handler is written as follows >>>>>>
////////////////////////////////////////////////////////////////////////////////
/////////
tanksToBeBuilt_so.onSync = function(tankList) {
trace("tank onsync");
for (var i in tanksToBeBuilt_so.data) {
if (tanksToBeBuilt_so.data != null) {
trace("trace test :"+"owner:"+tanksToBeBuilt_so.data.ownedBy+",
"+"TankName:"+tanksToBeBuilt_so.data.name);
}
}
};
////////////////////////////////////////////////
On the 2nd line of the above onSync I have a trace which is "trace("tank
onsync");".
When the app starts the trace works so the RSO IS being initialized.
Can anybody spot whats up with my code?
Thanks,
Barry.
d00mc0ck Guest
-
onSync not chronological
I've set up a basic chat app. I'm adding a new property for each message to a persistent remote SO called "chat_so". A message consists of a few sub... -
onSync question
How do I know when al the users have recived the information from the shared object when it is changed? Thank you! -
onSync not being called
..Net programmer trying my hand at flash com. I am coding up a HelpDesk app and am having trouble getting shared objects set up correctly. The code... -
DataGrid's UpdateCommand event handler and CancelCommand handler problem
I am having the same problem: the wrong event handler is being fired when column headings and page changes are clicked. I am using the datagrid... -
Fast signal handler switching & thread-specific handler.
jek_bask@ngs.ru (Evgeny Baskakov) writes: This is quite likely to crash on at least some pthread implementations (especially if sigaltstack was... -
d00mc0ck #2
Re: onSync Handler
Sorry,
After all that..........it was just a spelling mistake I didnt spot
d00mc0ck Guest
-
d00mc0ck #3
onSync Handler
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={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; //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;
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.
d00mc0ck Guest
-
FlashTastic #4
Re: onSync Handler
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
FlashTastic Guest



Reply With Quote

