Loading external Swf - sandbox violation

2019-06-05 13:29发布

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 !

3条回答
Juvenile、少年°
2楼-- · 2019-06-05 14:05

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...

查看更多
smile是对你的礼貌
3楼-- · 2019-06-05 14:10

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 );
查看更多
地球回转人心会变
4楼-- · 2019-06-05 14:15
This may be worked around by calling Security.allowDomain.

read the error.

查看更多
登录 后发表回答