Just wondering if
would be the equivalent ofCode:num1,num2,num3 = 5;
There are no compile errors, would it work?Code:num1=5; num2=5; num3=5;![]()

Just wondering if
would be the equivalent ofCode:num1,num2,num3 = 5;
There are no compile errors, would it work?Code:num1=5; num2=5; num3=5;![]()
If there are no compile errors it should be fine![]()
we're smiling but we're close to tears, even after all these years
Still no luck
Here's what I have so far, having rewritten some of it in AS3 (this is just the connection.as include - someone please tell me if I'm doing someting wrong)
Have tried adding crossdomain.xml to the root of the domain, also tried with/without the final null character in the policy response.
Instead of going to the policyfile log, it pops up in an error window now.
Extract of Java server code (which responds to policy request)Error #2044: Unhandled securityError:. text=Error #2048: Security sandbox violation: http://blah blah blah/VirtualRoom.swf cannot load data from 192.168.1.86:4049.
at VirtualRoom_fla::MainTimeline/frame3()
Code:... // It's checking the packet it received against a huge wad of if/else's (BP ik) } else if (line.equals("<policy-file-request/>")) { System.out.println("Answered policy request."); // This is shown, so the if() is definitely matching out.print("<cross-domain-policy>" + "<allow-access-from domain=\"*\" to-ports=\"*\" />" + "</cross-domain-policy>"+EOF); disconnect = true; } ...
The connection.as
Code:var serverHost:String = "192.168.1.86"; var serverPort:uint = 4049; // VirtualRoom Connection functions // Get socket policy from the same port. Security.loadPolicyFile("xmlsocket://" + serverHost + ":" + serverPort); // Show connecting text (timer) var cddd:int = 0; var connectionMessage:String="Connecting to server"; var connectingTextTimer:uint = setInterval(function(){ cddd++; statusBox.text=connectionMessage; for(var i:int=0;i<cddd%4;i++) statusBox.appendText("."); },500); // Socket + Socket Events var xmlSocket:XMLSocket=new XMLSocket(); xmlSocket.addEventListener(Event.CONNECT,socketConnect); xmlSocket.addEventListener(Event.CLOSE,socketClose); xmlSocket.addEventListener(DataEvent.DATA,socketReceive); function socketConnect(status):void{ if (status){ connectionMessage="Checking server"; sendToServer("h"); }else{ clearInterval(connectingTextTimer); messagebox("Cannot connect to server","Connection Issues");//,function(){_root.loadMovie(_root._url);}); statusBox.text="Connection failed"; clearInterval(connectingTextTimer); } } function socketReceive(rec):void{ var rec=rec.data.toString().trim().decodeHTML(); if(debugMode) messageBox(rec,"Packet Received"); var packetData=rec.substr(1,rec.length-1); switch(rec.substr(0,1)){ case "h": // Handshake packet loginForm.visible=true; statusBox.text="Connected"; clearInterval(connectingTextTimer); break; case "n": // Notice message (message box) packetData=packetData.split("|"); if(!packetData[0]) return void; if(packetData[1]) messageBox(packetData[1],packetData[0]); else messageBox(packetData[0]); return void; break; case "a": // Authenticated userData["id"]=packetData; gotoAndStop(4); break; default: if(debugMode) messageBox("Previous packet was unrecognised.","Error"); break; } } function socketClose(event):void{ trace("disconnected"); //unloadRoom(); messagebox("Server connection lost","Disconnected");//,function(){_root.loadMovie(_root._url);}); } function sendToServer(packet:String=""):void{ xmlSocket.send(packet+"\n"); } // Connect to server xmlSocket.connect(serverHost,serverPort);
Last edited by Apolva; 08-06-2010 at 08:51 PM.
I dunno what to say dude, I haven't crossed this bridge yet. You've probs checked this stuff, but here's some late night reading for you
http://livedocs.adobe.com/flex/2/doc...=00001950.html
http://www.adobe.com/devnet/flashpla...in_policy.html
http://www.adobe.com/devnet/articles...file_spec.html
Please, please, please let us know if you find a solution, will help me greatly!
we're smiling but we're close to tears, even after all these years
The first call to order is make sure the JAVA server is doing what it is meant to do.
Make a simple java client and see if it can successfully pull the policy file from the java server. Once you have done that, you know you can focus on the flash side of things.
I haven't read all that you have posted, will take a deeper look not to see if anything stands out.
Edit: Just skimming over the policy you are outputting, I'm not sure if flash requires the the xml opening tag. ( <?xml version="1.0"?> )
Edit2: And just another sort of obvious suggestion. In my personal usage I went for the direct route of serving the policy on port 843 (which is where flash checks first, then after a 3 second timeout moves on ) But that then is completely incorrect as you have already stated you are getting the request to give serve the policy.
Last edited by Source; 09-06-2010 at 01:16 AM.
Success!
I found this: http://zappmonkey.com/journal/flash-policy-server/
That did the trick, it seems they've changed it so that you can only serve it on port 843 now, rather than the port you're accessing (at least that's what I've found).
+Rep both for the suggestions
Still makes no sense as to why Flash was requesting the policy from the port you already had a connection to.
I know, it even requested it without theExtra note - because *nix machines protect ports 1024 and below, I had to run the server as root (with sudo)Code:Security.loadPolicyFile("xmlsocket://" + serverHost + ":" + serverPort);
My server (C#) handles both the Policy and Server of the program. Whenever a client connects it sends out the Policy whether they want it or not and it seems to work just fine.
Also,
didn't work because of white space which is on the end of the string.Code:line.equals("<policy-file-request/>")
I use this function
to remove the white space and return just the part of the string which we want.Code:private string removeWhite(string msg) { string ret = ""; int z = msg.Length; for (int i = 0; i < z; i++) { int c = msg.Substring(i, 1).ToCharArray()[0]; if (c != 0) { ret += msg.Substring(i, 1); } else { return ret; } } return ret; }
or instead you could use
if(line.startsWith("<policy-file-request/>") == true) {
Want to hide these adverts? Register an account for free!