Ask a Question related to Macromedia Flash Flashcom, Design and Development.

  1. #1

    Default 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

  2. Similar Questions and Discussions

    1. 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...
    2. onSync question
      How do I know when al the users have recived the information from the shared object when it is changed? Thank you!
    3. 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...
    4. 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...
    5. 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...
  3. #2

    Default Re: onSync Handler

    Sorry,
    After all that..........it was just a spelling mistake I didnt spot
    d00mc0ck Guest

  4. #3

    Default 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

  5. #4

    Default 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

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139