Let’s suppose you come across the following error while debugging your AIR app:
*** Security Sandbox Violation *** SecurityDomain 'file://.../art.swf' tried to access incompatible context 'app:/myapp.swf'
Let’s also suppose that you’re loading some artwork from art.swf – you’ve created some clips that you’re exporting for actionscript and you’re importing them in your app by using applicationDomain.getDefinition to get their class in to mypp. At some point in myapp you add some bits of that artwork to the stage you add some MouseEvents to a clip containing that artwork.
Suddenly when you try to interact with that clip, you start getting a whack of Security Sandbox Violations. Google to the rescue? Unfortunately, no. You will get a lot of Error #2048, 2122 posts but our simple art.swf doesn’t contain any code and isn’t trying to do anything funny. If you search for “*** Security Sandbox Violation ***” you’ll come across this stack overflow post which might give you an idea.
Perhaps Flash is trying to give the clip you imported from art.swf some kind of focus? A quick artwork.mouseEnabled = false, artwork.mouseChildren = false later and problem solved!
Some pseudocode to better demonstrate the solution:
// Load art.swf // import class "Art" from art.swf var my_art:Art = new art(); var my_clip:MovieClip = new MovieClip(); my_clip.addChild(my_art); // Listeners that do mouse things... my_clip.addEventListener(...); // At this point, you may get your sandbox violated.. The solution? my_art.mouseChildren = false; my_art.mouseEnabled = false; // Yay! Your security is safe