<?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="955" minHeight="600" creationComplete="init()">
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.controls.Alert;
import mx.rpc.events.ResultEvent;
import mx.rpc.soap.LoadEvent;
import mx.rpc.soap.WebService;
private var web:WebService;
protected function init():void
{
web=new WebService();
web.loadWSDL("http://10.19.1.55/staterain/rainSensor.asmx?WSDL");
web.addEventListener(LoadEvent.LOAD,testConn);
web.GetSensorState("-1");
web.GetSensorState.addEventListener(ResultEvent.RESULT, getNum);
}
public function testConn(event:Event):void
{
lbl0.text="连接成功";
}
public function getNum(event:ResultEvent):void
{
// txt1.text=event.result.toString();
var xmldata:XML=new XML(event.result);
// for each ( var name:XML in xmldata.sensor ) {
// Alert.show(name.sensorID);
// }
Alert.show(xmldata..sensorID);
// for each ( var name:String in xmldata.sensor ) {
// Alert.show(name);
// }
txt1.text=xmldata.toXMLString();
}
]]>
</fx:Script>
<s:layout>
<s:BasicLayout/>
</s:layout>
<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
<fx:XML id="myData" xmlns="">
<node lable="资料">
<node lable="Music">
<node lable="古典"/>
<node lable="摇滚"/>
<node lable="民歌"/>
</node>
<node lable="Movie">
<node lable="法国"/>
<node lable="美国"/>
</node>
</node>
</fx:XML>
</fx:Declarations>
<s:Label x="18" y="17" text="标签" width="413" height="56" fontSize="36" id="lbl0"/>
<mx:Tree x="438" y="148" width="310" height="291" labelField="@lable" dataProvider="{myData}"
folderOpenIcon="@Embed(source='../flex_src/weather/1.gif')" defaultLeafIcon="@Embed(source='../flex_src/weather/0.gif')"
folderClosedIcon="@Embed(source='../flex_src/weather/2.gif')"></mx:Tree>
<s:TextInput x="73" y="165" width="357" height="484" id="txt1"/>
</s:Application>