简体   繁体   English

AS3 Air远程外部swf无法访问本地apk

[英]AS3 Air remote external swf can not access local apk

I'm developing an android file by using flash cs5 air extention.我正在使用 flash cs5 空气扩展开发 android 文件。 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".我的“container.apk”从服务器加载“external.swf”。我希望能够从“external.swf”访问“container.apk”中的变量和函数。 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.但我无法从我的外部模块 swf(远程文件)访问我的容器(应用程序 file.apk)上的任何 function。我的意思是,我试图从加载的 swf 访问 container.apk 的函数。 Like when a button clicked on "external.swf" it should effect a function in "container.apk".就像单击“external.swf”按钮时一样,它应该会影响“container.apk”中的 function。

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** SecurityError:错误 #2047:安全沙箱违规:父级:http:// * * .com/external.swf 无法访问 app:/container.swf **

And the loading function of my container;以及我容器的装载function;

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.我认为这是设计使然,加载的 SWF 是沙盒的。

Imagine the scenario where you have a Flash website and want to load Flash games for example.想象一下,您有一个 Flash 网站并想要加载 Flash 游戏的场景。 If loaded children had access to parent, a malicious SWF could get server access through your loader SWF for example.例如,如果加载的子节点可以访问父节点,则恶意 SWF 可能会通过您的加载器 SWF 获得服务器访问权限。

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.通过访问 APK 及其权限,加载的 SWF 理论上可以接管电话,这也无济于事。

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.但是它应该反过来工作,加载程序主机应该能够访问加载的 SWF 中的任何内容,所以恐怕您必须考虑到这一点来构建您的应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM