flex学习笔记6-----数据通信HTTPService
2009-11-28 10:22
375 查看
查阅相关的帮助文档我们可以知道HTTPService一些常用的方法和属性:
属性
method:发送HTTP请求的方法
url : 请求服务的位置
request:发送请求的参数
requestTimeout:请求超时的时间
useProxy:是否使用代理的别名服务
方法:
send:参数为object类型默认为null,返回值类型为AsyncToken,执行一个HTTPService的请求
下面我们通过一个获取新浪体育新闻汇总的示例来说明HTTPService的使用
Code
<?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>
属性
method:发送HTTP请求的方法
url : 请求服务的位置
request:发送请求的参数
requestTimeout:请求超时的时间
useProxy:是否使用代理的别名服务
方法:
send:参数为object类型默认为null,返回值类型为AsyncToken,执行一个HTTPService的请求
下面我们通过一个获取新浪体育新闻汇总的示例来说明HTTPService的使用
Code
<?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>
相关文章推荐
- Java与Flex学习笔记(5)----Flex与Java通信之HttpService方式
- java Web与Flex通过HTTP service 通信 并解析Map 数据。
- Flex 与外部的数据通信(HTTPService,URLLoader和URLRequest)
- 利用HTTPService实现Flex与服务器端低数据量通信
- [Silverlight学习笔记]关于利用WCF RIA Service进行通信并在客户端获取数据
- Flex与外部数据通信URLLoader、HTTPService、 WebService
- Java开发学习笔记之三:HTTP客户请求数据格式
- Binder学习笔记(六)—— binder服务端是如何组织addService数据的
- Java与Flex学习笔记(4)----Flex与Java通信之RemoteObject方式
- flex 数据传输 httpservice, webservice, RemoteObject, socket
- Java与Flex学习笔记(21)----Flex与Java通信方式之WebService
- Flex学习笔记8——数据绑定
- Laravel学习笔记(二)---路由,CSRF,HTTP中间件,RESTFul风格控制器注册路由,视图间共享数据
- flex 通过HTTPService与php通信
- Flex : 利用HTTPService DataGrid从XML文件中加载数据
- FLEX 初学笔记之一,使用HTTPService读取Data.xml文件,显示于表示层
- Flex的HTTPService 学习001
- Flex 3入门教程: 用 HTTPService 加载外部数据
- Python学习笔记——Http通信requests请求
- iOS学习笔记(八)——iOS网络通信http之NSURLConnection