Two important points. 1 - SWF must have ability to loading binary data from any domain. 2 - SWF cant load policy XML file from url, cause upload form allows me only to upload swf files, so I cant include any other data. I tried:
Security.allowDomain("*");
But it works only for SWF files. I tried to embed policy XML file:
var dataXML:XML =
<?xml version="1.0"?>
<!-- http://www.foo.com/crossdomain.xml -->
<cross-domain-policy>
<allow-access-from domain="*" />
</cross-domain-policy>;
But Security.loadPolicyFile(url:String) allows only to set file url, not data. So my question is, how can I allow SWF to load binary files from different domains without having any additional file? URLLoader code:
var request:URLRequest = new URLRequest("http://differentdomain.com/binaryfile.dat");
var words:URLLoader = new URLLoader();
words.dataFormat = URLLoaderDataFormat.BINARY;
words.addEventListener(Event.COMPLETE, prepareFile);
words.addEventListener(IOErrorEvent.IO_ERROR, loadError);
words.addEventListener(SecurityErrorEvent.SECURITY_ERROR, secureError);
words.load(request);
This will make an security error, if file is from different domain than SWF file. Thanks for any help.
Its possible to get binary data from JavaScript using ExternatInterface in AS3 code. Here is cross-browser library for reading files binary: binary reader and later version jDataView Hope this will help someone. Thanks to Jonatan Hedborg for idea.