Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

as3 AIR for android - Application-sandbox content ERROR

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

like image 780
Papa De Beau Avatar asked May 03 '12 05:05

Papa De Beau


2 Answers

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) { };

like image 59
bnns Avatar answered Sep 28 '22 01:09

bnns


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.

like image 21
sharon Avatar answered Sep 28 '22 01:09

sharon