as3 AIR for android - Application-sandbox content ERROR

帅比萌擦擦* 提交于 2020-01-03 13:11:15

问题


THE GOAL:

I am trying to allow externally loaded swf files communicate with each other that are locally loaded from the device. I need to be able to have access to vars and functions and objects. I have accheived this while loading swf content from the web here: as3 externally loaded swf from network to control externally loaded swf from network

BUT WHEN I GIVE THE USER THE OPTION TO LOAD FROM DEVICE OR FROM ONLINE... The device swf files can't communicate with each other. Specifically the loaded swf can not get info from its parent.

Below is the code that works when loading from online:

var InsideConent:Object = this.parent.parent as Object; //// GIVES ACCESS TO "Content.swf"
var ItWorksNow:Sprite = MovieClip(InsideConent.TWO.content).ChildInTWO;  /// 

The device doesn't like this code:

Security.allowDomain("*");

But when run online it works fine. Below is the error I get when I run it locally loaded from the APP package.

THE ERROR:

SecurityError: Error #3207: Application-sandbox content cannot access this feature. at flash.system::Security$/allowDomain() at Products_fla::MainTimeline/frame1() Cannot display source code at this location.

THE QUESTION: Is there anything I can do to make allow security domain to work locally on an AIR FOR ANDROID device so I don't have to change my code? - thanks


回答1:


If you put a try catch around that line it won't throw an error if it fails. And this way when your code will work on the web and as an app. (apps don't need to allowDomain b/c they can download everything by default and that is why it fails.)

try {Security.allowDomain("*");}catch (e) { };




回答2:


From my experience you can load remote swfs from another domain that is configured correctly with the crossdomain xml. something like: https://developers.arcgis.com/flex/guide/using-crossdomain-xml.htm

You can load swf with code, but if you try to access the stage for example it will fail.

Also, if in your original project (hosted all on a web server, you used common static variables or singeltons, it will not succeed. My solution was adding functions on those files which receive the objects I needed to work with.




回答3:


As far as I know you can't execute code from loaded swfs in AIR, you can still use multiple swfs to dislay assets but any code will give that error.



来源:https://stackoverflow.com/questions/10425505/as3-air-for-android-application-sandbox-content-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!