0 Replies Latest reply on Jul 30, 2007 11:23 AM by penitenziagite

    Simultanous object movement via XMLSocket

    penitenziagite
      Hi
      I am having a problem with XMLSocket data sending and loading. I want to create a game like chess: two players connected, when one of them takes his move, other can see it on the screen. So I wrote the script ("circle" is a piece):


      mySocket = new XMLSocket();

      XMLSocket.prototype.onData = function() {
      circleBPositionX.text = bX - 25;
      circleBPositionY.text = bY - 25;
      circlePositionX.text = X - 25;
      circlePositionY.text = Y - 25;

      circle._x = X - 25; trace("x: " +circle._x);
      circle._y = Y - 25; trace("y: " +circle._y);

      createEmptyMovieClip("traceRoute", 0);
      traceRoute.moveTo(bX, bY);
      traceRoute.lineStyle(3, 0xff0000);
      traceRoute.lineTo(X, Y);
      };

      circle.onRelease = function() {
      bX = _root.circle.bX;
      bY = _root.circle.bY;
      X = _root.circle.X;
      Y = _root.circle.Y;
      //mssg = bX+ "\n" +bY+ "\n" +X+ "\n" +Y+ "\n";
      mySocket.send(bX, bY, X, Y, mess);
      }

      mySocket.connect("127.0.0.1", 9999);

      The problem is when one player drags the circle, the other can see circle`s position as "undefined" (while "trace("x: " +circle._x)" and "trace("x: " +circle._y)" returns correct data).
      I am using ActionScript2 and PHP socket server; same as the one in kirupa.com tutorial ( http://www.kirupa.com/developer/flas...ts_flash8.htm).

      Can anyone help me?