Use XML socket Connect event and Data event : XMLSocket : Network Flash / Flex / ActionScript examples


Flash / Flex / ActionScript examples » Network » XMLSocket »

 

Use XML socket Connect event and Data event


 

package {
  import flash.display.Sprite;
  import flash.events.Event;
  import flash.events.DataEvent;
  import flash.net.XMLSocket;

  public class SocketExample extends Sprite {
  
    private var xmlSocket:XMLSocket;
  
    public function SocketExample(  ) {
      xmlSocket = new XMLSocket(  );
      
      xmlSocket.addEventListenerEvent.CONNECT, onConnect );
      
      xmlSocket.addEventListenerDataEvent.DATA, onData );

      xmlSocket.connect"localhost"2900 );
    }
    
    private function onConnectevent:Event ):void {
      xmlSocket.send"<test/>" );  
    }

    private function onDataevent:DataEvent ):void {
      traceevent.data );
      
      var response:XML = new XMLevent.data );
      
      traceresponse.test.@success );
    }
  }
}

        



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


Flash / Flex / ActionScript examples

 Navioo Network
» XMLSocket