简体   繁体   English

Adobe Air中的安全行为

[英]Security behaviour in Adobe Air

I am trying to load external SWFs in my Adobe AIR App. 我正在尝试在Adobe AIR应用程序中加载外部SWF。 The loaded SWF is trying to access an URL to retrieve some informations via XML. 加载的SWF正在尝试访问URL,以通过XML检索某些信息。 When starting the SWF by itself it works fine. 单独启动SWF时,效果很好。 When loading the SWF from the File.applicationStorageDirectory i will get an Security-Error because the loaded App is executed in a local-with-filesystem Sandbox appareantly. 从File.applicationStorageDirectory加载SWF时,我会收到一个安全错误,因为已加载的应用程序在本地文件系统沙箱中适当执行。 First Question : Is there a way to change this? 第一个问题 :有办法改变吗? That the loaded SWF is running in a network Sandbox? 加载的SWF是否在网络沙箱中运行?

Since that first attempt didn't worked i've moved the SWF to the app:// directory. 由于第一次尝试无效,因此将SWF移至app://目录。 Now i'll get a Security-Error because there is no policy file on the Server available where the XML data should be retrieved. 现在,我将收到一个“安全性错误”,因为服务器上没有可用的策略文件可检索XML数据。 Second Question : Why is the policy file not necessary when running the SWF by itself, but is necessary when trying to load the data from the application Sandbox? 第二个问题 :为什么在单独运行SWF时策略文件不是必需的,而在尝试从应用程序沙箱中加载数据时却是必需的? What am i doing wrong? 我究竟做错了什么?

Thanks in advance! 提前致谢!

Here is my solution. 这是我的解决方案。

I am doing an ActionScript-based app btw. 我正在做一个基于ActionScript的应用程序。 My goal here is the create an AIR Application that loads different modules on demand from a given internet ressource. 我的目标是创建一个AIR应用程序,该应用程序可以根据需要从给定的Internet资源加载不同的模块。 The two applications are using the child/parentSandboxBridge to communicate. 这两个应用程序正在使用child / parentSandboxBridge进行通信。

I was using the SWFLoader class but did not correctly pass the LoaderContext with allowLoadBytesCodeExecution (or allowCodeImport for AIR2.0). 我使用的是SWFLoader类,但未通过allowLoadBytesCodeExecution(或AIR2.0的allowCodeImport)正确传递LoaderContext。 As i was passing a LoaderContext with the mentioned variable, i was getting an VerifyError: Error #1053: Illegal override of activate in mx.managers.SystemManagerProxy since the AIR Application is done with Flex 4.0 and the loaded SWF is compiled with Flex 3.5. 当我传递带有提到的变量的LoaderContext时,我得到了VerifyError:错误#1053:mx.managers.SystemManagerProxy中的activate的非法覆盖,因为AIR应用程序是用Flex 4.0完成的,而加载的SWF是用Flex 3.5编译的。

The reason that error was thrown although the loadForCompatibility property was set to true was, that the SWFLoader class does not set the necessary applicationDomain for compatibility when a LoaderContext Object is passed. 尽管将loadForCompatibility属性设置为true,但引发错误的原因是,传递LoaderContext对象时,SWFLoader类未设置必要的applicationDomain以实现兼容性。 So i did the applicationDomain setting myself and everything works like a charm. 所以我做了applicationDomain来设置自己,一切都像个魅力。 If anyone is interested in this procedure, just look into the SWFLoader::loadContent Method. 如果有人对此过程感兴趣,只需查看SWFLoader :: loadContent方法。 In Flex 4 the interesting part starts at line 1836. 在Flex 4中,有趣的部分从1836行开始。

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

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