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.addEventListener( Event.CONNECT, onConnect );
xmlSocket.addEventListener( DataEvent.DATA, onData );
xmlSocket.connect( "localhost", 2900 );
}
private function onConnect( event:Event ):void {
xmlSocket.send( "<test/>" );
}
private function onData( event:DataEvent ):void {
trace( event.data );
var response:XML = new XML( event.data );
trace( response.test.@success );
}
}
}
Related examples in the same category