flex学习笔记6-----数据通信HTTPService

查阅相关的帮助文档我们可以知道HTTPService一些常用的方法和属性:

属性

method:发送HTTP请求的方法

url : 请求服务的位置

request:发送请求的参数

requestTimeout:请求超时的时间

useProxy:是否使用代理的别名服务

方法:

send:参数为object类型默认为null,返回值类型为AsyncToken,执行一个HTTPService的请求

下面我们通过一个获取新浪体育新闻汇总的示例来说明HTTPService的使用


<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="sinaSport.send()">
<mx:Style>
     global
     {
         fontSize:14pt;
     }
</mx:Style>
    
<mx:HTTPService id="sinaSport" url="http://rss.sina.com.cn/roll/sports/hot_roll.xml" useProxy="false">
    
</mx:HTTPService>
    
<mx:Panel x="53" y="90" width="975" height="461" layout="absolute" title="新浪体育要闻汇总 ">
    
<mx:DataGrid id="sportContent" x="23.5" y="10" width="911.5" dataProvider="{sinaSport.lastResult.rss.channel.item}" height="175">
        
<mx:columns>
            
<mx:DataGridColumn  width="300" headerText="标题" dataField="title"/>
            
<mx:DataGridColumn  width="150" headerText="作者" dataField="author" />
            
<mx:DataGridColumn  width="150" headerText="日期" dataField="pubDate" />
        
</mx:columns>
    
</mx:DataGrid>
    
<mx:TextArea x="23" y="193" width="912" height="183" htmlText="{sportContent.selectedItem.description}"/>
<mx:LinkButton x="855" y="384" label="详细信息" click="navigateToURL(new URLRequest(sportContent.selectedItem.link))"/>
    
</mx:Panel>
</mx:Application>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值