flex学习进度7之网络访问

访问本地资源的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>


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值