项目中需要由一个main.swf 、 a.swf 、b.swf构成,其中a.swf与b.swf中各自有一类名为btn的类元件,当在调试过程中,加载 a.swf 和 b.swf 进入main.swf时,new btn()会得到两个不同的结果,究其原因是应用程序域ApplicationDomain问题。
当他们加载进入main.swf中时,应用程序域为同一个,那么他们就会彼此覆盖,不同则不相互影响。
用SWFloader举例说明:
1 var loader:SWFLoader; 2 var context:LoaderContext; 3 context = new LoaderContext(true, new ApplicationDomain(ApplicationDomain.currentDomain), SecurityDomain.currentDomain) ; 4 loader= new SWFLoader(url,{onComplete:onLoadSWF,onProgress:progressHandler,width:1349,height:725,context:context}); 5 loader.load();
附上网上找的设置其他域代码:
1 context.applicationDomain = new ApplicationDomain(ApplicationDomain.currentDomain)//子域; 2 context.applicationDomain = ApplicationDomain.currentDomain//同域; 3 context.applicationDomain = new ApplicationDomain()//新域;

浙公网安备 33010602011771号