AS3 Loading SWF Files Cross-Domain


/ Published in: ActionScript 3
Save to your folder(s)

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.


Copy this code and paste it in your HTML
  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. }

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.