Debug Flex Application Against Different Server Machine
Once in a while one of my server co-workers will ask me to test something on my current version of our client Flex application. Generally they are asking me because they will use the same version of the client application as long as possible, which in some cases could be a couple weeks. They also know that every morning I get a fresh copy of everything and always try to run the “latest greatest”.
The other day I received one of these types of queries, but with a twist; they wanted me to use my client application against their server. Oddly enough this had never come up before, so I set out to get this working. Oddly enough it took me a bit of searching before I found the solution, considering the end result was so simple. Going forward I will refer to my machine as Machine A (client) and my coworkers machine as Machine B (server). So if you jumped right in and tried to point your client right at Machine B you would get this error,
- Create a new xml file named crossdomain.xml on Machine A.
- Download my sample cross domain file sample-crossdomain.xml (note these values allow any domain to access your server so you should fine tune it for your case if in a production environment).
- Change the name to crossdomain.xml
- Send the crossdomain.xml file to the person using Machine B.
- On Machine B place the crossdomain.xml into the ROOT folder of the app server, so you can go to MACHINEB/crossdoma… and see the file from Machine B.
- Open up the main application mxml file of your Flex application.
- Add an initialization event handler to the application if one doesn’t already exist.
- Add this line to the initialization handler: Security.loadPolicyFile(”MachineB/crossdoma…”);
- Finally wherever you have defined the URL for your AMF channel needs to be updated to point to Machine B.