2011-07-04 3 views
0

여기에 샌드 박스 문제가 있기 때문에 원격 swf로로드 된 자산을 프록시 화하는 약간의 해결 방법을 찾고 있습니다.원격 swf에서 swf로드를 catch하고 편집 할 수 있습니까?

는 현재 원격 SWF를로드, 나는 다음과 같은 오류 얻을 비트 맵 그리는 시도 후 :가 된 SWF의 & 변화를 잡을 수 있다면 지금

Security sandbox violation: BitmapData.draw: http://urlhere cannot access http://remotehost/clothes/bg/bg_10438411_bg.swf. This may be worked around by calling Security.allowDomain. 

을, 내가보고 싶은 원격 SWF를로드하는 . 그래서 내가 그들을 대신 swf로 PHP 파일을 통해로드 할 수 있습니다. 기본적으로에서 SWF를로드 URL을 편집 .. 어떤 제안?

+0

약간의 코드를 보여줄 수 있습니까? 이해하기 쉽습니다. – Taurayi

+0

이게 뭔가요? http://active.tutsplus.com/tutorials/actionscript/quick-tip-using-a-php-proxy-to-load-assets-into-flash/ – gltovar

+0

네, 그러나 원격 SWF에 대한 실제 액세스 권한이 없습니다. 그래서 나는 여전히 요청을 받고 URL을 편집해야합니다. –

답변

0

BitmapData.draw()를 사용하여로드 된 swf의 스냅 샷을 그리는 것처럼 보입니다. 로드하는 swf를 보유하고있는 서버에 crossdomain.xml이 필요하거나 서버 측 스크립트를 통해 프록시 처리해야합니다.

crossdomain.xml이있는 경우 LoaderContext를 로더의 load() 메서드의 두 번째 매개 변수로 전달하여 명시 적으로 크로스 도메인 검사를 요청할 수 있습니다. 보안 요구 사항이 충족되지 않으면 SecurityErrorEvent이 전달됩니다. 다만,

var loader:Loader = new Loader(); 
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler); 
loader.contentLoaderInfo.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityError); 
loader.load(new URLRequest('yoursite.com/yourfile.swf'),new LoaderContext(true)); 

function completeHandler(event:Event):void{ 
    var clone:BitmapData = new BitmapData(1,1);//create a small bitmap to try and draw into 
    try{//draw the contents 
     clone.draw(event.target.content); 
    }catch(error:SecurityError){//expect security error 
     trace('SecurityError while loading',event.target.url,'details\n',error.message);  
    } 
} 
function securityError(event:SecurityErrorEvent):void{ 
    trace(event.target.url,event); 
} 

또한 의해 IOErrorEvent 및이 HTTPStatusEvent에 대한 리스너를 추가 할 수 있습니다 또한, 당신의 BitmapData의 무승부() 메서드를 호출 할 때 던져 SecurityError를 잡아 그것을 변경할 된 LoaderInfo의 URL을 사용하고 그러나 당신이 알아서 사용해야합니다 문제가 생겼을 때 (파일 누락, 잘못된 URL 등)

관련 문제