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. //
  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(''), context);
  10. }else{
  11. l.load(new URLRequest('extFile.swf'));
  12. }


Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.