flex socket

var mysocket:Socket=new Socket();
mysocket.addEventListener(Event.CLOSE,closeHandler);
mysocket.addEventListener(Event.CONNECT,connectHandler);
mysocket.addEventListener(IOErrorEvent.IO_ERROR,ioErrorHandler);
mysocket.addEventListener(SecurityErrorEvent.SECURITY_ERROR,securityErrorHandler);
mysocket.addEventListener(ProgressEvent.SOCKET_DATA,socketDataHandler);
Security.loadPolicyFile("http://192.168.2.188/crossdomain.xml")
mysocket.connect("192.168.2.188",6666);

function closeHandler(event:Event):void {
        trace("closeHandler: " + event);
}
function connectHandler(event:Event):void {
        trace("connectHandler: " + event);
}
function ioErrorHandler(event:IOErrorEvent):void {
        trace("ioErrorHandler: " + event);
}
function securityErrorHandler(event:SecurityErrorEvent):void {
        trace("securityErrorHandler: " + event);
}
function socketDataHandler(eventrogressEvent):void {
        trace("socketDataHandler: " + event);
}

你可能感兴趣的:(xml,socket,Security,Flex)