2011-04-09 3 views
0

동일한 도메인의 SWF 파일 두 개를 메인 플래시 플레이어로 차례로로드하려고합니다 ... 첫 번째로드 됨 ... 그것은 잘 작동하지만 다른 하나의 첫 번째 사람의 actionscript freaks (stop() 함수가 작동을 멈춘다)를로드하려고 할 때 또한 두 번째 샌드 박스 위반 (# 2121) .Flash AS3로드 중 2 다른 SWF에서 null 객체 참조 오류가 발생했습니다.

나는이 문제에 대한 이유를 찾을 수없는

...

첫 번째 SWF의로드 코드 :

... 
ldr = new Loader(); 
ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, swfLoaded); 
ldr.load(new URLRequest(swf1filename)); 
... 
function swfLoaded(e:Event):void { 
    mcExt = MovieClip(e.currentTarget.content); 
    mcExt.x = 0; 
    mcExt.y = 32; 
    addChild(mcExt); 
} 

두 번째 SWF의로드 코드 :

... 
function showSWF2(){ 
     if (end_movie_swf == null && endMcExt== null){ 
      end_movie_swf = new Loader(); 
      end_movie_swf.contentLoaderInfo.addEventListener(Event.COMPLETE, Swf2Loaded); 
      end_movie_swf.load(new URLRequest(endSwffilename)); 

     }else{ 
      endMcExt.gotoAndPlay("show"); 
     } 
    } 
    ... 
function Swf2Loaded(e:Event):void { 
    trace(e); 
    endMcExt = MovieClip(e.currentTarget.content); 
    end_movie_swf.contentLoaderInfo.removeEventListener(Event.COMPLETE, endSwfLoaded); 
    endMcExt.x = 0; 
    endMcExt.y = 0; 
    addChildAt(endMcExt,3); 
    endMcExt.gotoAndStop("show"); 
} 

이 오류가 발생합니다.

TypeError: Error #1009: Cannot access a property or method of a null object reference. 
    at SWF1::MainTimeline/frame13() 
+1

을 아무도 도울 수있는 코드를 참조하지 않고. – robertp

답변

0

나는이 세 가지 swf가 모두 동일한 ApplicationDomain 내에서 작동하고 있다고 생각합니다. 즉, 실수로 모든 swf에서 동일한 객체에 대한 참조를 사용하고 있음을 의미합니다.

로드 된 swf에 캡슐화 된 ApplicationDomain 내에서 작동하도록 지시하는 경우 LoaderContext를 보내야합니다. 이처럼

:

var loaderContext:LoaderContext = new LoaderContext(); 
loaderContext.applicationDomain = new ApplicationDomain(); 

ldr.load(new URLRequest(swf1filename),loaderContext); 

두 번째 Loader 객체와 동일한 작업을 수행.

링크에서 자원 : http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/system/ApplicationDomain.html

+0

그것이 작동해야하는 것처럼 들리지만 ... 예상대로 작동 ... – hdmi3killer

+0

나는 혼란스러워. :) 내 솔루션이 도움이 되었습니까? – Tjofras

+0

불행히도 ... – hdmi3killer