5D艺术网首页
商城
|
资讯
|
作品
|
博客
|
教程
|
论坛
登录
注册
加为好友
发短消息
来自:
性别:秘密
最后登录:2007-04-12
http://Billows.5d.cn/
首页
|
新闻
|
话题
|
博客
|
相册
|
艺术作品
|
社交关系
|
留言板
|
社交圈
2006/01/24 | Flash中使用WebServiceConnector
类别(Flash&AS2)
|
评论
(0)
|
阅读(190)
|
发表于 16:17
以前公司做的一个WebServiceConnector例子,贴出来共享:
XML.prototype.ignoreWhite = true;
var res = function (ev) {
initCityList(ev.target.results);
};
_root.myWS.addEventListener("result", res);
var subres = function (ev) {
//initCityList(ev.target.results);
trace(ev.target.results);
initWeatherInfo(ev.target.results);
};
_root.subWS.addEventListener("result", subres);
function initCityList(res:String) {
_root.test.text = res;
var tempXML:XML;
tempXML = new XML(_root.test.text);
root = tempXML.firstChild;
var nodeArray:Array = root.childNodes;
for(var i=0; i<nodeArray.length; i++) {
var one = nodeArray[i];
//trace("cityName = " + one.childNodes[1].firstChild);
_root.grid_content.addItem({国家:String(one.childNodes[0].firstChild),
城市:String(one.childNodes[1].firstChild)});
}
}
var myListener = new Object();
var self = this;
myListener.cellPress = function(event) {
var temp = grid_content.getItemAt(event.itemIndex);
//trace(temp);
_root.loadMoreInfo(temp.国家,temp.城市);
};
grid_content.addEventListener("cellPress", myListener);
function loadMoreInfo(country,city) {
trace("country = " + country + " city = " + city);
//var a:Array = new Array();
//a["CountryName"] = String(country);
//a["CityName"] = String(city);
//_root.subWS.params = a;
_root.ddd = new dd();
ddd.CountryName = country;
ddd.CityName = city;
_root.subWS.params = ddd;
_root.subWS.trigger();
};
function initWeatherInfo(res:String) {
_root.test.text = res;
var tempXML:XML;
tempXML = new XML(_root.test.text);
root = tempXML.firstChild;
var nodeArray:Array = root.childNodes;
_root.weather.text = "";
_root.weather.text += "Location: \n" + nodeArray[0].firstChild + "\n";
_root.weather.text += "Time: \n" + nodeArray[1].firstChild + "\n";
_root.weather.text += "Wind: \n" + nodeArray[2].firstChild + "\n";
_root.weather.text += "Visibility: \n" + nodeArray[3].firstChild + "\n";
_root.weather.text += "SkyConditions: \n" + nodeArray[4].firstChild + "\n";
_root.weather.text += "Temperature: \n" + nodeArray[5].firstChild + "\n";
_root.weather.text += "DewPoint: \n" + nodeArray[6].firstChild + "\n";
_root.weather.text += "RelativeHumidity: \n" + nodeArray[7].firstChild + "\n";
_root.weather.text += "Pressure: \n" + nodeArray[8].firstChild + "\n";
}
0
评论
Comments
日志分类
首页
[116]
Flash&AS2
[56]
FMS
[3]
Flex&AS3
[5]
Asp
[5]
My Works
[13]
My Life
[34]