0 Replies Latest reply on May 8, 2008 6:25 PM by tobycraftse

    socket communication

    tobycraftse
      For socket communication, I better use an external script instead of
      adding the script to the 1st frame in the movie??

      since otherwise, if the movie keep looping, I will try to open many
      many socket then?

      from what version of flash support external script? (.as)



      import ftk.net.BufferedSocket;

      BufferedSocketExample();

      function BufferedSocketExample() {

      trace('start...');
      var socket:BufferedSocket = new BufferedSocket('127.0.0.1',
      12345);
      socket.onConnect = function() {
      trace('connected');
      };
      socket.onFailure = function() {
      trace('failure');
      };
      socket.onTimeout = function() {
      trace('timeout');
      };
      socket.onClose = function() {
      trace('close');
      };
      socket.onData = function(d) {
      trace('data: '+d);
      };
      socket.connect();
      for (var i:Number = 0; i<10; i++) {
      socket.send('msg-'+i);
      }//~ socket.close();
      }