?废话不多说,上代码:
?
- <?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"??
- ???????????????creationComplete="init()"?
- ???????????????xmlns:mx="library://ns.adobe.com/flex/mx"?minWidth="955"?minHeight="600">?
- ????<fx:Script>?
- ????????<![CDATA[?
- ????????????import?mx.collections.ArrayCollection;?
- ????????????import?mx.controls.Alert;?
- ????????????import?mx.rpc.events.FaultEvent;?
- ????????????import?mx.rpc.events.ResultEvent;?
- ?????????????
- ????????????private?function?init():void?
- ????????????{?
- ????????????????//天气预报?
- ????????????????webService.getWeatherbyCityName("苏州");?
- ????????????}?
- ?????????????
- ????????????/***************************天气预报***************************/?
- ????????????private?function?onLoad(event:ResultEvent):void{????
- ????????????????var?weatherInfo:ArrayCollection?=?(event.result)?as?ArrayCollection;????
- ????????????????for(var?i:int=0;i<weatherInfo.length;i++){??
- ????????????????????myWeatherReport.text+=weatherInfo[i]+"?|?";????
- ????????????????}????
- ????????????}?
- ?????????????
- ????????????private?function?faultHandler(event:FaultEvent):void{????
- ????????????????Alert.show(event.fault.toString(),"WebService?Error");????
- ????????????}?
- ?????????????
- ????????]]>?
- ????</fx:Script>?
- ?????
- ?????
- ????<fx:Declarations>?
- ?????????
- ?????????
- ????????<s:WebService?id="webService"?wsdl="http://www.webxml.com.cn/WebServices/WeatherWebService.asmx?wsdl"????
- ??????????????????????useProxy="false"?showBusyCursor="true"?result="onLoad(event)"?fault="faultHandler(event)"/>?
- ????</fx:Declarations>?
- ?????
- ?????
- ?????
- ????<mx:Text?styleName="weatherFont"?id="myWeatherReport"?x="450"?y="60"/>?
- </s:Application>