<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="200" minHeight="200">
<fx:Declarations>
<mx:WebService id="webService" wsdl="http://www.webxml.com.cn/WebServices/WeatherWebService.asmx?wsdl"
showBusyCursor="true" result="onLoad(event)" fault="faultHandler(event)"/>
</fx:Declarations>
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.controls.Alert;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.utils.ArrayUtil;
private function onLoad(event:ResultEvent):void{
//Alert.show(event.result.toString(),"WebService Results");
var weatherInfo:ArrayCollection = (event.result) as ArrayCollection;
for(var i:int=0;i <weatherInfo.length;i++){
myWeatherReport.text+=weatherInfo[i]+"/n";
}
}
private function faultHandler(event:FaultEvent):void{
Alert.show(event.fault.toString(),"WebService Error");
}
protected function button1_clickHandler(event:MouseEvent):void
{
webService.getWeatherbyCityName(cityname.text);
}
]]> </fx:Script> <s:Panel width="224" height="276"> <s:TextInput id="cityname" text="北京" x="10" y="213"></s:TextInput> <s:Button label="查询" x="142" y="213" click="button1_clickHandler(event)"></s:Button> <s:TextArea id="myWeatherReport" height="196" width="201" editable="false" x="11" y="9"></s:TextArea> </s:Panel> </s:Application>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。