I'm developing an application that requires embedding a flex file (.swf) in a jsp.
The scenario is as follows:
The index.jsp is running from eclipse IDE on tomcat server at localhost:8080 in the application NewWebApp. I am using the <object> tag to embed a .swf file in it by giving the complete path to the file, which is located in the Flex Builder working folder within the application that it was created in. Within the file, I am passing the path to a servlet running on another application(built using Jdeveloper - running on OC4J server) on my computer using URLLoader. This servlet returns an xml document. On running from Flex Builder, I get the expected results.
But when the same .swf file gets called as an object embedded in a jsp as described above, I get the following error:
Error #2044: Unhandled securityError:. text=Error #2048: Security sandbox violation: http://localhost:8080/NewWebApp/Myflexfile.swf cannot load data from http://<IP Address>/<Application Context path>/sampleservlet
It seems from this that the embedded MyFlexFile.swf is considered to reside within the NewWebApp java application (the loading URL). And it is trying to access data from the specified servlet. Now, <Application Context Path> is a not the actual name of any folder, but a property specified for context path of the application. So I added a crossdomain.xml file in the root folder, i.e. inside the WEB-INF folder (which contains the web.xml) and also just outside of it (from where the index.jsp of the application is loaded when it starts) in the application which contains the servlet.
But.. but.. the errors still persists.. what can I do?.. please help..
In Eclipse, go to Project Properties and select the Flex Compiler. Add -use-network=false to the "additional compiler options".
OR, If using the command line compiler, add -use-network=false to your build command.