用户名: 密码: 免费注册 忘记密码? 网站地图 | 加入收藏 | 设为首页
首页 | 新闻 | 工具 | 系统 | 办公 | 聊天 | 多媒体 | 网页 | 运营 | 平面 | 欣赏 | 数据库 | 程序 | 服务器 | 组网
网页 | 3dmax | Ghost | Windows Xp| Dreamweaver | photoshop | Flash | office | Alexa | Css | QQ | Asp | PHP | Jsp | Access
Flash MX 2004入门 | 网站推广策略 | CorelDRAW入门 | ASP学习 | 网站建设大师功 | Word入门
  iTbulo.com > 学院 > 网页制作教程 > Flash教程 > Action应用 > 文章正文
Webservice使用实例-各地天气预报|各国货币转换
iTbulo.COM 2006-2-12 aw()
各地天气预报

各地货币转换

相关核心代码:
//天气预报代码 by www.Awflasher.com
import mx.services. *;
function getWeather ()
{
  //Initialization
  var gw_ws : WebService = new WebService ("http://www.webservicex.net/globalweather.asmx?WSDL");
  var x0 : Number = 5;
  var y0 : Number = 1;
  var h0 : Number = 400;
  var w0 : Number = 120;
  var cityName : String = "Wuhan";
  var countryName : String = "China";
  _root.createTextField ("w_txt", 1, x0, y0, h0, w0)
  var my_fmt = new TextFormat ()
  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;
  //end of Initialization
  //connect ws
  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;
  }
}
function parseXML (_weatherData : String)
{
  /*
  XML Struct
  <?xml version="1.0" encoding="utf-16"?>
  <CurrentWeather>
  <Location>Wuhan, China (ZHHH) 30-37N 114-08E 23M</Location>
  <Time>Jul 27, 2005 - 02:00 AM EDT / 2005.07.27 0600 UTC</Time>
  <Wind> from the SW (220 degrees) at 11 MPH (10 KT):0</Wind>
  <Visibility> 2 mile(s):0</Visibility>
  <SkyConditions> partly cloudy</SkyConditions>
  <Temperature> 95 F (35 C)</Temperature>
  <DewPoint> 84 F (29 C)</DewPoint>
  <RelativeHumidity> 71%</RelativeHumidity>
  <Pressure> 29.53 in. Hg (1000 hPa)</Pressure>
  <Status>Success</Status>
  </CurrentWeather>
  */
  var weatherData : XML = new XML (_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 (var i = 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 );
}
function showResult (_t : String , _w : String , _v : String , _skyC : String , _tl : String , _th : String , _rh : String , _press : String)
{
  _t = "<b>发布时间:</b>" + _t;
  _w = "<b>风速:</b>" + _w;
  _v = "<b>可见度:</b>" + _v;
  //_skyC = "<b>空气情况:</b>" + _skyC;
  _tl = "<b>最低温度:</b>" + _tl;
  _th = "<b>最高温度:</b>" + _th;
  _rh = "<b>相对湿度:</b>" + _rh;
  _press = "<b>气压:</b>" + _press;
  w_txt.htmlText = _t + "\n" + _w + "\n" + _v + "\n" + _tl + "\n" + _th + "\n" + _rh + "\n" + _press ;
}
getWeather ();
// getCurrency_as.as by awflasher.com(货币转换代码)
import mx.services. *;
init ();
function init ()
{
  // initialize the Curreny names and contries
  var myCurrencyArray : Array = new Array ( "AFA-阿富汗尼", "ALL-阿尔巴尼亚币", "DZD-第纳尔", "ARS-比索", "AWG-弗罗林", "BSD-巴哈马币", "BHD-Bahraini Dinar", "BDT-孟加拉币", "BBD-巴巴多斯岛币", "BMD-百慕大币", "BTN-不丹币", "BOB-玻利维亚币", "BWP-博茨瓦纳币", "BRL-巴西币", "BND-文莱币", "BIF-布隆迪币", "KHR-柬埔寨瑞尔", "CAD-加拿大币", "CLP-智利比索", "COP-哥伦比亚币", "KMF-科摩罗币", "CRC-科隆", "HRK-Croatian Kuna", "CUP-Cuban Peso", "CYP-Cyprus Pound", "CZK-Czech Koruna", "DKK-Danish Krone", "XCD-东加勒比币", "EGP-埃及磅", "SVC-El Salvador Colon", "EEK-Estonian Kroon", "ETB-Ethiopian Birr", "FKP-Falkland Islands Pound", "GMD-Gambian Dalasi", "GHC-Ghanian Cedi", "GIP-直布罗陀币", "XAU-Gold Ounces", "GTQ-危地马拉币", "GNF-几内亚币", "GYD-圭亚那币", "HTG-Haiti Gourde", "HNL-Honduras Lempira", "HUF-Hungarian Forint", "ISK-Iceland Krona", "INR-Indian Rupee", "IDR-Indonesian Rupiah", "IQD-Iraqi Dinar", "ILS-Israeli Shekel", "JMD-Jamaican Dollar", "JOD-约旦币", "KZT-Kazakhstan Tenge", "KES-Kenyan Shilling", "KRW-Korean Won", "KWD-Kuwaiti Dinar", "LAK-Lao Kip", "LVL-拉脱维亚币", "LBP-Lebanese Pound", "LSL-莱索托币", "LRD-利比亚币", "LTL-立陶宛币", "MKD-马其顿币", "MGF-马达加斯加币", "MWK-马拉维币", "MYR-Malaysian Ringgit", "MVR-Maldives Rufiyaa", "MTL-Maltese Lira", "MRO-Mauritania Ougulya", "MUR-Mauritius Rupee", "MXN-Mexican Peso", "MDL-Moldovan Leu", "MNT-Mongolian Tugrik", "MAD-Moroccan Dirham", "MZM-莫桑比克币", "MMK-Myanmar Kyat", "NAD-纳米比亚币", "NPR-尼泊尔币", "ANG-Neth Antilles Guilder", "NZD-新西兰币", "NIO-Nicaragua Cordoba", "NGN-Nigerian Naira", "KPW-朝鲜圆", "NOK-Norwegian Krone", "OMR-Omani Rial", "PKR-Pakistani Rupee", "XPD-Palladium Ounces", "PAB-Panama Balboa", "PGK-Papua New Guinea Kina", "PYG-Paraguayan Guarani", "PEN-Peruvian Nuevo Sol", "PHP-菲律宾币", "XPT-Platinum Ounces", "PLN-Polish Zloty", "QAR-Qatar Rial", "ROL-Romanian Leu", "RUB-Russian Rouble", "WST-Samoa Tala", "STD-Sao Tome Dobra", "SAR-Saudi Arabian Riyal", "SCR-Seychelles Rupee", "XAG-Silver Ounces", "SGD-新加坡元", "SKK-Slovak Koruna", "SIT-Slovenian Tolar", "SBD-所罗门群岛币", "SOS-索马里币", "ZAR-南非币", "LKR-Sri Lanka Rupee", "SHP-St Helena Pound", "SDD-苏丹币", "SRG-Surinam Guilder", "SZL-Swaziland Lilageni", "SEK-瑞典币", "CHF-瑞士法郎", "SYP-叙利亚币", "TZS-坦桑尼亚先令", "THB-泰国铢", "TOP-Tonga Pa’anga", "TND-突尼斯币", "TRL-土耳其里拉","EUR-欧元", "USD-美元", "GBP-英镑","AUD-澳元", "JPY-日元","HKD-港币","MOP-中国澳元", "TWD-中国台币", "CNY-人民币");
  //
  for (var i in myCurrencyArray)
  {
    c1_cb.addItem (myCurrencyArray [i]);
    c2_cb.addItem (myCurrencyArray [i]);
  }
  var myClick : Object = {};
  myClick.click = function (e)
  {
  
    c1 = (c1_cb.selectedItem.label).slice(0,3);
    c2 = (c2_cb.selectedItem.label).slice(0,3);
    getRate(c1 , c2)
    
  }
  cc_btn.addEventListener ("click", myClick);
  
}
function getRate (c1:String, c2:String)
{
  trace(")")
  //Initialization
  var cc_ws : WebService = new WebService ("http://www.webservicex.net/CurrencyConvertor.asmx?WSDL");
  var x0 : Number = 9;
  var y0 : Number = 71;
  var h0 : Number = 38;
  var w0 : Number = 230;
  _root.createTextField ("w_txt", 1, x0, y0, w0, h0)
  var my_fmt = new TextFormat ()
  my_fmt.color = 0x000033;
  my_fmt.font = "宋体";
  my_fmt.size = 12 ;
  my_fmt.bold = false;
  w_txt.setNewTextFormat (my_fmt);
  w_txt.selectable = false;
  w_txt.html = true;
  w_txt.wordWrap = true;
  //end of Initialization
  //connect ws
  w_txt.text = "正在连接货币转换服务器 ...";
  _root.loader.gotoAndStop ("getCC")
  wsResultObj = cc_ws.ConversionRate (c1, c2);
  wsResultObj.onResult = function (result : String )
  {
    _root.loader.gotoAndStop ("rest")
    showResult (result);
  }
  wsResultObj.onFault = function (fault : Object )
  {
    
    trace (fault.faultCode + "." + fault.faultstring);
    w_txt.text = fault.faultCode + "." + fault.faultstring;
  }
  
}
function showResult (result:String)
{
  w_txt.htmlText = c1_cb.selectedItem.label.slice(4,c1_cb.selectedItem.label.length) + " 合 " + c2_cb.selectedItem.label.slice(4,c2_cb.selectedItem.label.length) + " 汇率为 " + "<b>"+result+"</b>";
}
//右击天气预报源文件下载
testwebservice.rar
文章搜索
相关资讯
相关文章 相关下载
没有相关文章
焦点信息