AS3 Load external SWF from remote URL


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



Copy this code and paste it in your HTML
  1. // Loading a SWF from a remote server requires you to set the correct securityDomain
  2. // Use the Security.sandboxType to check this
  3. // Testing a SWF locally doesn't require securityDomain
  4. // In a browser it does (Security.REMOTE)
  5.  
  6. import flash.system.*;
  7. import flash.net.*;
  8.  
  9. if(Security.sandboxType == Security.REMOTE)
  10. {
  11. var context:LoaderContext = new LoaderContext();
  12. context.securityDomain = SecurityDomain.currentDomain;
  13. }
  14.  
  15. var ldr:Loader = new Loader();
  16. ldr.load(new URLRequest("http://www.remoteDomain.com/remoteSWF.swf"), context);

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.