Hi,
I'm trying to communicate my flash application with my server. Either the problem is my code is working on Flash Professional, but I have prepared all my interface on Flash Builder which uses Flex 4 -SDK. My code does not work on Flex Project.
The problem is not security file. I can not solve the problem. What are the possible reasons?
Kind Regards.
If necessary my code is below [working on FlashPro but not on Flex ! ]
import flash.net.*;
import flash.events.Event;var host:String = new String("127.0.0.1");
var port:int = 8080;
var securityFile:String = "http://localhost:1755/.../..../s....xml";
var bagli:Boolean = false;
var socket:Socket = null;
var veri:String = new String("----");
btnGonder.addEventListener(MouseEvent.MOUSE_DOWN, tiklantiEvent);
function buildSocket():void
{           
trace("beginning....");
    socket = new Socket();
    socket.addEventListener(Event.CONNECT, onConnect);
    socket.addEventListener(Event.CLOSE, onClose);
    socket.addEventListener(ErrorEvent.ERROR, onError);
    socket.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
    socket.addEventListener(ProgressEvent.SOCKET_DATA, onResponse);
Security.allowDomain(host);
Security.loadPolicyFile(securityFile);
try {
    socket.connect(host, port);
    bagli = true;
    trace("--- connection...");
} catch (error:Error) {
    trace("--- connection failed...");
    socket.close();
}
}
 function send(string:String):void {
    socket.writeUTFBytes(string);
    socket.flush();
}
 function onConnect(event:Event):void {
    trace("connect");
}
 function onClose(event:Event):void {
    trace("closed");
}
 function onError(event:IOErrorEvent):void {
    trace("connection erron");
}
 function onIOError(event:IOErrorEvent):void {
    trace("data error");
}
 function onResponse(event:ProgressEvent):void {
    var string:String = socket.readUTFBytes(socket.bytesAvailable);
    trace(string);
}
function (sender:Event):void {
    trace("clicked button....");
    buildSocket();
    trace("------------------");
}