var geo:Geolocation;
if (Geolocation.isSupported)
{
geo = new Geolocation();
geo.addEventListener(GeolocationEvent.UPDATE, updateHandler);
geo.setRequestedUpdateInterval(10000);
}
else
{
geoTextField.text = "Geolocation feature not supported";
}
function updateHandler(event:GeolocationEvent):void
{
lat = event.latitude.toString();
lon = event.longitude.toString();
var lat:String;
var lon:String;
trace(lat);
trace(lon);
var weather_xml_url:String = "http://api.openweathermap.org/data/2.5/weather? lat="+lat+"&lon="+lon+"&units=metric&lang=lv&mode=xml";
trace(weather_xml_url);
var weather:XML = new XML();
var weather_url:URLRequest = new URLRequest(weather_xml_url);
var weatherLoader:URLLoader = new URLLoader(weather_url);
trace(weather);
weatherLoader.addEventListener(Event.COMPLETE, weatherLoaded);
function weatherLoaded(e:Event):void
{
weather = XML(weatherLoader.data);
temp_txt.text = [email protected];
wind_txt.text = [email protected]+ "m/s";
var weather_icon:String = [email protected];
icons_mc.gotoAndStop(weather_icon);
}
}
추적 할 때 (lat); 추적 (lon); 완벽하게 작동합니다. 추적 할 때 (weather_xml_url); 완벽하게 작동합니다. 추적 할 때 (날씨); 그것은 날 null을 보내십시오XML이 작동하지 않습니다 GPS
XML을 읽지 못하는 이유 웹에 xml 주소가 정확했지만 WeatherLoader 기능이로드되지 않았습니다.
이 날씨가 새로운 XML (weatherLoader.data)로 변경됩니다. 아무것도 바꿀 필요가 없습니다 ... – user3332885
아, 미안 해요, 주요 문제를 보지 못했습니다 : 당신은 load() 메소드를 호출하지 않습니다. 나는 대답을 업데이트했다. – Crabar
미안하지만, 난 이해가 안되네 ... – user3332885