Listen to the connect event : XMLSocket « Network « Flash / Flex / ActionScript






Listen to the connect event

 
package {
  import flash.display.Sprite;
  import flash.events.*;
  import flash.net.XMLSocket;

  public class SocketExample extends Sprite {
  
    private var socket:XMLSocket;
  
    public function SocketExample(  ) {
      socket = new XMLSocket(  );
      
      socket.addEventListener( Event.CONNECT, onConnect );
      
      socket.connect( "localhost", 2900 );
    }
    
    private function onConnect( event:Event ):void {
      trace( "The xml socket is now connected..." );  
    }
    
  }
}
Security.loadPolicyFile("http://www.java2s.com/crossdomain.xml");

        








Related examples in the same category

1.Use XMLSocket to retrieve data
2.Use XML socket Connect event and Data event