AS3 Loading SWF Files Cross-Domain


 / Published in: ActionScript 3
 

URL: http://www.bigspaceship.com/blog/labs/flash-files-domains-and-security-errors-oh-my/

From the Big Spaceship Labs website. This is a useful workaround for the following error message ... SecurityError: Error #2142: Security sandbox violation: local SWF files cannot use the LoaderContext.securityDomain property.

  1. // Please read the full blog post from Big Spacehip to understand the issue.
  2. // http://www.bigspaceship.com/blog/labs/flash-files-domains-and-security-errors-oh-my/
  3.  
  4. var l:Loader = new Loader();
  5. l.contentLoaderInfo.addEventListener(Event.COMPLETE, _onLoadComplete_handler);
  6. if(Security.sandboxType == Security.REMOTE){
  7. var context:LoaderContext = new LoaderContext();
  8. context.securityDomain = SecurityDomain.currentDomain;
  9. l.load(new URLRequest('http://domain.com/extFile.swf'), context);
  10. }else{
  11. l.load(new URLRequest('extFile.swf'));
  12. }

Report this snippet  

You need to login to post a comment.