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 ); } }}
Name (required)
email (will not be published) (required)
Website