2012-02-20 25 views
0
 protected function button1_clickHandler(event:MouseEvent):void 
     { 

      Security.allowDomain("*.googleapis.com"); 
      Security.allowDomain("*.google.com"); 

      var q : URLLoader = new URLLoader(); 
       q.addEventListener(Event.COMPLETE, onGeocodingComplete); 
       q.load(new URLRequest('http://maps.googleapis.com/maps/api/geocode/json?latlng=40.548555,24.558466&sensor=false')); 


     } 

     protected function onGeocodingComplete(event : Event) : void 
     { 
      Alert.show('geocoding succeed'); 
     } 

我試着用上面的代碼,但它扔給我:Flex:securityError嘗試使用google api反轉地理代碼?

sandbox violationError #2044: Unhandled securityError:. text=Error #2048: Security sandbox violation... 
  • 我怎麼能直接訪問反向地理編碼服務trought閃光?

    因爲帶有Flash API的地理編碼器不能提供足夠的數據。

+1

您可以使用JavaScript做地理編碼的東西,並通過數據使用ExternalInterface的 – Neil 2012-02-20 14:03:28

+0

羅閃爍。主要想法是遠離Javascript。 - 在我的情況下,Javascript是這樣的:「儘量避免使用Javascript」:D(無論如何,對其他人來說這可能是個好主意) – 2012-02-20 15:26:14

回答

1

創建新的PHP頁面mypage.php

<?php 
    $ch = curl_init(); 
    curl_setopt($ch, CURLOPT_URL, "http://maps.googleapis.com/maps/api/geocode/json?latlng=40.548555,24.558466&sensor=false"); 
    curl_setopt($ch, CURLOPT_HEADER, 0); 
    curl_exec($ch); 
    curl_close($ch); 
?> 

閃光:

q.load(new URLRequest("mypage.php")); 
+0

這是個好主意,但是不會對服務器執行服務器端查詢。無論如何這是好主意,以及:) – 2012-02-20 15:26:54

相關問題