Cross Domain ExternalInterface “Error calling method on NPObject”

前端 未结 6 1379
一向
一向 2020-12-08 20:53

I am trying to enable communication between Javascript and Flash via ExternalInterface across domains. The Javascript works great when it is located on the same domain as th

6条回答
  •  孤城傲影
    2020-12-08 21:39

    Since you are loading multiple swfs, you may need to include the security settings in each of those swfs on domain B that are loaded.

    You may also need a loader context with the appropriate security settings.

    import flash.system.LoaderContext;
    import flash.system.ApplicationDomain;
    import flash.system.Security;
    import flash.system.SecurityDomain;
    import flash.net.URLRequest;
    import flash.net.URLLoader;
    
    var context:LoaderContext = new LoaderContext(true, ApplicationDomain.currentDomain, (Security.sandboxType == Security.REMOTE) ? SecurityDomain.currentDomain : null);
    var l:Loader = new Loader();
    l.load(new URLRequest("http://example.com/myswf.swf"), context);
    

提交回复
热议问题