2012-05-29 4 views
1

google 정적 이미지 api에서 플래시로 이미지를로드하려고합니다. 플래시를로드하려고하면 플래시가 샌드 박스 문제에 대해 불평합니다. 후에도 Google에서 정책 파일을로드하려고합니다.로드 중 google maps 정적 이미지를 플래시에 넣기

Security.loadPolicyFile("http://maps.googleapis.com/crossdomain.xml");

이 주변에 어떤 방법이 있나요? 또는이 방식으로 이미지를로드하는 것이 단순히 불가능합니까?

+0

로컬 또는 웹 서버에서 테스트 중이십니까? – crooksy88

+1

일부 코드를 표시하십시오. 다른 도메인에서 이미지를로드해도 보안 sandobx 오류가 발생하지 않아야합니다. 그러나 이러한 이미지의 비트 맵 데이터에 액세스하려고하면 보안 오류가 발생합니다. –

+0

나는이 문제를 해결했다. 당신이 맞다. 나는 로더 클래스를 사용하고 있었고, 상태를 확인하려고했다. – user379468

답변

1
 var loader1:Loader = new Loader(); 
     var lctx1:LoaderContext = new LoaderContext(true); 
     loader1.contentLoaderInfo.addEventListener(Event.INIT, doImgInit); 
     loader1.load(new URLRequest("http://maps.googleapis.com/maps/api/staticmap?center=Brooklyn+Bridge,New+York,NY&zoom=14&size=600x400&maptype=satellite&sensor=false&scale=4"), lctx1); 
    private function doImgInit(evt:Event):void 
    { 
     trace("DO IT") 
     // get a reference to the LoaderInfo object in which the image is loaded 
     var lInfo:LoaderInfo = evt.target as LoaderInfo; 

     // this variable is used as reference to the image in the end. 
     var dO:DisplayObject; 

     // try to access the "content" property of the loader, if it works, there is a crossdomain.xml file. 
     try{ 
      dO = lInfo.loader.content; 
     } 

     // if there wasn't one, we need to put the loader inside another object in order to manipulate it 
     catch(err:SecurityError) 
     { 
      // create a new Sprite to contain the loaded image 
      var sprt:Sprite = new Sprite(); 
      // add the loader to the sprite 
      sprt.addChild(lInfo.loader); 
      // get a reference to this sprite in the dO variable 
      var dO:DisplayObject = sprt as DisplayObject; 
     } 

     // from here on you can do anything to the dO variable, rotate it, draw it unto a bitmapData, move it around.. 
     // but first don't forget to add to to some container that is on the stage so you can see it! 
    } 
+0

sandbox 문제가 발생하지 않고 bitmapdata를 그릴 수 있습니까? – Mattias