Loading external Swf - sandbox violation
I need a help ... an urgent one !!! I tried so hard to figured it out .. but I couldn't .. so I appreciate your help so much ..
I'm developing an Air App using flash ... the app loads an external SWF file dynamically through an xml ... the SWF file has a movieclip that has a listener (ON click )
function mouseDow开发者_JAVA百科nHandler(event:MouseEvent):void {
navigateToURL(new URLRequest(clickURL));
}
Everything is working fine until I click on this movieclip ... it displays the below message
SecurityError: Error #2121: Security sandbox violation: navigateToURL: http://www.mydomainexample.com/maskot/avatar.swf cannot access YAHOO.COM for example. This may be worked around by calling Security.allowDomain.
Any help ! because I really have a deadline !
Thank you so much for any help !
Actually Security.allowDomain won't work since we are talking about AIR.
Searching around at this link provides a possible answer: http://code.google.com/p/maashaack/wiki/ApplicationDomain
var context:LoaderContext = new LoaderContext( false, AD );
context.allowLoadBytesCodeExecution = true;
loader.loadBytes( urlloader.data, context );
Securit.allowDomain is irrelevant here because that is only for indicating where other SWFs/apps can be located to access your app from.
What you are trying to do is a security violation and there is no direct way around it. But you could try a couple things:
- vazor's idea
- Write code in your primary app which adds an event listener to your button once the external swf is loaded and then call navigateToURL from your handler that exists in the primary app. I have tried this method and it works. If you need to you could also load the actual URL from the external swf.
This answer might not be useful unless your deadline was 4+ years in the future...
This may be worked around by calling Security.allowDomain.
read the error.
精彩评论