Saturday, November 15, 2008

Flex's Error #2048: Security sandbox violation

I was running the flex application within the C:\ path while it was trying to access documents using web services from http://localhost:4076. It immediately threw an error. After much googling I found that the main reason is Flex do not allow a program to access information from outside the domain it was called from.

To get around this problem, you have three choices:
  1. Add a crossdomain.xml file to the server with the data.
  2. Upload your SWF file to the same server as the data service.
  3. Create a proxy on your server that calls the data service, and put your SWF file on the same server as the proxy.

The simplest method is to create a crossdomain.xml file. The instructions are:

A crossdomain.xml file is an XML file that provides a way for a server to indicate that its data and documents are available to SWF files served from certain domains, or from all domains. The crossdomain.xml file must be in the web root of the server that the Flex application is contacting. For more information about configuring crossdomain.xml files, see the technote on the Macromedia website: http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=tn_14213.

No comments: