访问本地资源的xml
<?xml version="1.0" encoding="utf-8"?>
<ss>
<a>aaaa</a>
<b>bbbb</b>
<city>城市</city>
<updatetime>更新时间</updatetime>
<wendu>温度</wendu>
<fengli>风力</fengli>
<shidu>湿度</shidu>
<fengxiang>风向</fengxiang>
</ss>
天气预报
<?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="sendToServer_creationCompleteHandler(event)">
<s:layout>
<s:BasicLayout/>
</s:layout>
<fx:Script>
<![CDATA[
import mx.events.FlexEvent;
import mx.rpc.events.ResultEvent;
protected function httpServerHandle(event:ResultEvent):void
{
// TODO Auto-generated method stub
var t:String=event.result.resp.city
result_city.text=t;
var t1:String=event.result.resp.fengli
result_fengli.text=t1;
var t2:String=event.result.resp.fengxiang
result_fengxiang.text=t2;
var t3:String=event.result.resp.shidu
result_shidu.text=t3;
var t4:String=event.result.resp.updatetime
result_updatetime.text=t4;
var t5:String=event.result.resp.wendu
result_wendu.text=t5;
}
protected function sendToServer_creationCompleteHandler(event:FlexEvent):void
{
// TODO Auto-generated method stub
send_Server.send();
}
]]>
</fx:Script>
<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
<fx:Model id="dataModel" source="assets/extXml.xml">
</fx:Model>
<s:HTTPService id="send_Server"
url="http://wthrcdn.etouch.cn/WeatherApi?citykey=101010100"
result="httpServerHandle(event)" />
</fx:Declarations>
<s:Label id="sLabel" text="{dataModel.b}" x="296" y="35" fontSize="19" backgroundColor="#851E1E"/>
<mx:Form y="136" symbolColor="#1F2793" chromeColor="#A27272" horizontalCenter="0" dropShadowVisible="true" cornerRadius="4" backgroundColor="#95A7E9" contentBackgroundColor="#B46DCE" borderAlpha="0.55">
<mx:FormHeading label="天气预报" width="140" chromeColor="#752929" color="#59A82E"/>
<mx:FormItem label="{dataModel.city}" height="20" id="city">
<s:TextArea width="100" height="20" id="result_city"/>
</mx:FormItem>
<mx:FormItem label="{dataModel.updatetime}" height="20" id="updatetime">
<s:TextArea width="100" height="20" id="result_updatetime"/>
</mx:FormItem>
<mx:FormItem label="{dataModel.wendu}" height="20" id="wendu">
<s:TextArea width="100" height="20" id="result_wendu"/>
</mx:FormItem>
<mx:FormItem label="{dataModel.fengli}" height="20" id="fengli">
<s:TextArea width="100" height="20" id="result_fengli"/>
</mx:FormItem>
<mx:FormItem label="{dataModel.shidu}" height="20" id="shidu">
<s:TextArea width="100" height="20" id="result_shidu"/>
</mx:FormItem>
<mx:FormItem label="{dataModel.fengxiang}" height="20" id="fengxiang">
<s:TextArea width="100" height="20" id="result_fengxiang"/>
</mx:FormItem>
</mx:Form>
</s:Application>