AS3 Air remote external swf can not access local apk
I'm developing an android file by using flash cs5 air extention. I know the basic crossdomain policy and server to server connections. And I searched many pages but there is no solution about this.
My "container.apk" loads "external.swf" from the server.. And I want to be able to reach the variables and functions in "container.apk" from "external.swf". But I can't reach any function on my container (application file .apk) from my external module swf (remote file).. I mean, I'm trying to reach container.apk's functions from the loaded swf. Like when a button clicked on "external.swf" it should effect a function in "container.apk".
Also here are some error codes that I'm getting ;
SecurityError: Error #2047: Security sandbox violation: parent: http://**.com/external.swf cannot access app:/container.swf**
And the loading function of my contain开发者_C百科er ;
var l:Loader = new Loader;
var externalSWF:MovieClip;
var contextC:LoaderContext = new LoaderContext();
contextC.checkPolicyFile = false;
contextC.allowCodeImport = true;
l.load(new URLRequest(filePath), contextC);
l.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
function loadComplete(evt:Event){
l.contentLoaderInfo.removeEventListener(Event.COMPLETE, loadComplete);
externalSWF = l.content as MovieClip;
MovieClip(root).addChild(externalSWF);
}
I think this is by design, loaded SWFs are sandboxed.
Imagine the scenario where you have a Flash website and want to load Flash games for example. If loaded children had access to parent, a malicious SWF could get server access through your loader SWF for example.
It also doesn't help that what you're trying to do is even more dangerous, by having access to the APK and its permissions, a loaded SWF could in theory take over the phone.
It should however work the other way round, the loader host should be able to access anything inside the loaded SWF, so I'm afraid you'll have to architect your app with this in mind.
精彩评论