Bitmapdatas dynamically loaded from zip are not trusted locally and thus uneditable
This is a very strange problem.
I am using external resources for a game I am making. One of the resources is a zip file containing 100 images (thumbnails). The purpose of this zip is simply that it will make loading these resources much easier, simpler, and as I am storing these resources on Amazon S3, significantly cheaper.
This has been working without a hitch, until I moved and ran the swf in a non-trusted location.
Now, when I try and load the first thumbnail I get this:
Loader/get content()
SecurityError: Error #2148: SWF file file:///C|/Users/Tom/Desktop/Jigsaw.swf cannot access local resource file:///C|/Users/Tom/Desktop/Jigsaw.swf/[[DYNAMIC]]/1. Only local-with-filesystem and trusted local SWF files may access local resources.
This occurs when I try and access Loader.content, which I need to do as some bitmapdatas need to be altered after loading.
I've run into a similar error when originally trying to load external resources and converting them into bitmapDatas. This was fixed using a policy file.
I figured that the policy file was the problem, but then I tried embedding the .zip into the swf instead of loading it externally, like this:
[Embed(source="../res/images/thumbnails.zip", mimeType="application/octet-stream")]
But even that threw up the same error.
What's happening is a byteArray is cleverly being converted into a BitmapData, but in the process it becomes untrusted by Flash.
I cannot find any way of converting this byte.
I've tried using several different as3 zip class packages, but they all fall at the same hurdle.
Here's the essential code:
var zip:FZip = new FZip();
zip.loadBytes(zipData);
var file:FZipFile = zip.getFileByName("image1.jpg");
var loader:Loader = new Loader();
loader.loadBytes(file.content);
root.addChild(loader);
loader.addEventListener("click", function(e) {
var bd:BitmapData = e.target.content.bitmapData;
bd.applyFilter(bd, bd.rect, new Point(), new BlurFilter(20, 20, 1));
} );
This is the part that really makes this weird... When I test this, it works fine, when I upload it online, fine. The only time I get the error is when the SWF is being run locally, but in an untrusted location.
Clearly, these security measures are going a bit fudged if it works without a hitch online, but doesn't locally, you'd expect it to be the other way round.
As far as I can tell there is nothing potentially dangerous with my code. It's from a trusted location (policy file is working).
I've found another unfortunate person who came across the same problem but never got an answer:
http://www.actionscript.org/forums/showthread.php3?t=261853
I've tried EVERYTHING. bitmapdatas dynamically loaded from zips are uneditable for no apparent reason.... unless the swf is being opened in a trusted location or anywhere online.
