Loading external Swf - sandbox violation

丶灬走出姿态 提交于 2020-01-23 19:55:11

问题


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 mouseDownHandler(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 !


回答1:


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



回答2:


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:

  1. vazor's idea
  2. 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...




回答3:


This may be worked around by calling Security.allowDomain.

read the error.



来源:https://stackoverflow.com/questions/2771787/loading-external-swf-sandbox-violation

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