Webservice使用实例-各地天气预报|各国货币转换
作者 佚名技术
来源 服务器技术
浏览
发布时间 2012-07-08
各地天气预报 各地货币转换 相关核心代码: //天气预报代码 by www.AwFlasher.com importmx.services.*; functiongetWeather() { //Initialization vargw_ws:WebService=newWebService("http://www.webservicex.net/globalweather.asmx?WSDL"); varx0:Number=5; vary0:Number=1; varh0:Number=400; varw0:Number=120; varcityName:String="Wuhan"; varcountryName:String="China"; _root.createTextField("w_txt",1,x0,y0,h0,w0) varmy_fmt=newTextFormat() my_fmt.color=0x000033; my_fmt.font="Tahoma"; my_fmt.size=11; my_fmt.bold=false; w_txt.setNewTextFormat(my_fmt); w_txt.selectable=false; w_txt.HTML=true; //endofInitialization //connectws w_txt.text="正在连接气象站服务器..."; wsResultObj=gw_ws.GetWeather(cityName,countryName); wsResultObj.onResult=function(result:String) { _root.loader.gotoAndStop("rest") parseXML(result); } wsResultObj.onFault=function(fault:Object) { trace(fault.faultCode+"."+fault.faultstring); w_txt.text=fault.faultCode+"."+fault.faultstring; } } functionparseXML(_weatherData:String) { /* XMLStruct <?xmlversion="1.0"encoding="utf-16"?> <CurrentWeather> <Location>Wuhan,China(ZHHH)30-37N114-08E23M</Location> <Time>Jul27,2005-02:00AMEDT/2005.07.270600UTC</Time> <Wind>fromtheSW(220degrees)at11MPH(10KT):0</Wind> <Visibility>2mile(s):0</Visibility> <SkyConditions>partlycloudy</SkyConditions> <Temperature>95F(35C)</Temperature> <DewPoint>84F(29C)</DewPoint> <RelativeHumidity>71%</RelativeHumidity> <Pressure>29.53in.Hg(1000hPa)</Pressure> <Status>Success</Status> </CurrentWeather> */ varweatherData:XML=newXML(_weatherData); var_time:String; //3 var_wind:String; //5 var__visibility:String; //7 var__SkyConditions:String; //9 var_templ:String; //11 var_temph:String; //13 var__Pressure:String; //15 var_relativeH:String; //17 weatherData.ignoreWhite=true; for(vari=3;i<=17;i+=1) { switch(weatherData.childNodes[1].childNodes[i].nodeName) { case"Time": _time=weatherData.childNodes[1].childNodes[i].firstChild; break; case"Wind": _wind=weatherData.childNodes[1].childNodes[i].firstChild; break; case"Visibility": __visibility=weatherData.childNodes[1].childNodes[i].firstChild; break; case"SkyConditions": __SkyConditions=weatherData.childNodes[1].childNodes[i].firstChild; break; case"Temperature": _temph=weatherData.childNodes[1].childNodes[i].firstChild; break; case"DewPoint": _templ=weatherData.childNodes[1].childNodes[i].firstChild; break; case"RelativeHumidity": _relativeH=weatherData.childNodes[1].childNodes[i].firstChild; break; case"Pressure": __Pressure=weatherData.childNodes[1].childNodes[i].firstChild; break; default: break; } } showResult(_time,_wind,__visibility,__SkyConditions,_templ,_temph,_relativeH,__Pressure); } functionshowResult(_t:String,_w:String,_v:String,_skyC:String,_tl:String,_th:String,_rh:String,_press:String) { _t="<b>发布时间:</b>"+_t; _w="< |
凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢! |
你可能对下面的文章感兴趣
关于Webservice使用实例-各地天气预报|各国货币转换的所有评论