正在加载...

天气预报和汇率都可以在左边的“blog小贴士”找到最新版
===========以下过期============

有任何问题,希望大家提醒一下:)谢谢!
各地天气预报

单击显示

attachments/200507/28_100150_ws.swf

各国货币转换 (懒得翻译了,翻了一些主要的,不知道有没有漏比较重要的)

单击显示

attachments/200507/28_141330_getcurrency.swf

相关核心代码:

//天气预报代码 by www.Awflasher.comimport 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>”;
}

//特别感谢Luar的书^___^

//右侧天气预报源文件下载 –

点击下载

还没找到您要的东西?Google试试看吧,
Google更注重原创、时效性好的文章:


本文相关评论: 才 14 条评论
  1. raindays 2005-07-27 07:56:45

    很不错,AW不过应该是“最高湿度”不是“最高温度”

  2. frank 2005-07-28 02:28:43

    赞 [lol]

  3. procyon 2005-07-28 03:12:55

    [cool] 恩 走前冒个泡

    赞哈子

  4. FlankerMX 2005-07-29 09:12:43

    是as2.0与RIA这本书吧,写得的确不错呢,你都看到那么后面了啊,我还在前面啃呢~

  5. rison 2005-08-13 10:27:31

    k,看你们研究的这么欢,偶调整一下也要开始加油了

  6. Clear912 2005-08-27 08:49:29

    今天又借走你一段代码,哈哈 [lol]

  7. Neo 2006-08-23 02:16:12

    左边的那个贴士似乎只用parse一下xml用不着webservice了吧@@

  8. aw 2006-08-23 02:45:53

    左边那个是xml,没有走ws.因为ws.net不提供中文的详细天气情况.这个只是教程罢了.

  9. transomwu 2006-09-16 08:20:46

    你好,翻译的也能不能做做,多谢了

  10. shiyunzyh 2007-01-31 12:20:18
  11. baqiwei000 2007-04-09 12:38:47

    我也要天气预报

  12. 金柑子 2007-05-03 02:48:09

    怎么用哦?怎么看不懂呀?????

  13. 阳光 2007-05-12 03:52:26

    你的发明太有使用价值了 希望我也能成为其中的受益者

  14. baby 2008-09-08 06:07:13

    有没有java 版的?

[支持Ctrl+Enter]为了我们大家和家人的安全,留言请慎重!
声明:
1、本站仅与见过面的个人博客交换链接,见此文
2、留言时的头像是Gravatar提供的服务。如果您有兴趣并且有闲暇时间,可以看看这里的介绍