Flex远程访问获取数据--HTTPService
编写service类:
package services {
import com.adobe.serialization.json.JSON;
import log.LogUtil;
import mx.collections.ArrayCollection;
import mx.collections.XMLListCollection;
import mx.controls.Alert;
import mx.rpc.events.ResultEvent;
import mx.rpc.http.mxml.HTTPService;
public class CategoryService extends HTTPService {
[Bindable]
public var categoryArray:ArrayCollection;
public var testFlag:Boolean = true;
public function CategoryService(rootURL:String=null, destination:String=null) {
super(rootURL, destination);
this.url = "http://192.168.1.210:8081/xxx.action";
//url为远程请求接口
addEventListener(ResultEvent.RESULT, handleCategoryResult);
}
private function handleCategoryResult(event:ResultEvent):void{
var rawData:String = String(event.result);
trace(rawData);
LogUtil.debug("CategoryService",rawData);
var o:Object = com.adobe.serialization.json.JSON.decode(rawData);//对结果进行json转换
categoryArray = new ArrayCollection(o.result);
}
}
}
结果集接收之后进行json格式转换,需要导入as3corelib.swc
在XML中引入:
<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
<services:CategoryService id="categoryService"/>
</fx:Declarations>
在方法中调用:
<?xml version="1.0" encoding="utf-8"?>
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" width="342" height="60" xmlns:services="services.*" initialize="group1_initializeHandler(event)">
<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
<services:CategoryService id="categoryService"/>
</fx:Declarations> <fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.events.FlexEvent; import spark.events.IndexChangeEvent; protected function group1_initializeHandler(event:FlexEvent):void
{
if(categoryService.testFlag){
categoryService.localTest();
}else{
categoryService.send();
} } ]]>
</fx:Script> <s:DropDownList id="categoryList" x="92" y="29" width="174"
dataProvider="{categoryService.categoryArray}"
labelField="name"
prompt="请选择"
change="updateSelection(event);"
/> </s:Group>
Flex远程访问获取数据--HTTPService的更多相关文章
- Flex动态获取数据,服务中断报错
1.错误原因 2.错误原因 由上面提示可知,软件引起的链接中断,导致出错 3.解决办法 检查数据库链接,重新启动服务
- WCF+Restfull服务 提交或获取数据时数据大小限制问题解决方案
近日在使用wcf的restfull架构服务时遭遇到了提交大数据的问题. 大数据包含两种情形: 1)单条数据量过大. 2)提交或获取的数据条数过多. 在测试时发现,默认设置下当单条JSON数据大于30K ...
- python httplib get和post获取数据
httplib 下的 status http请求的状态 200 404 500... reason 返回答复 OK或者 FAULRE read() 读取内容 get方法: #!/usr/bin/e ...
- 从SQLite获取数据完成一个产品信息展示
在ios实际开发当中,我们常常用到Core Data做为数据储存首选.但在处理一些大量复杂的数据值且数据之间相互关联的时候,这就不得不使用关系型数据库来实现.例如一个导航程序,自身应该包含大量的地图自 ...
- MySQL随机获取数据的方法,支持大数据量
最近做项目,需要做一个从mysql数据库中随机取几条数据出来. 总所周知,order by rand 会死人的..因为本人对大数据量方面的只是了解的很少,无解,去找百度老师..搜索结果千篇一律.特发到 ...
- AngularJS SQL 获取数据
使用PHP从MySQL中获取数据: <!DOCTYPE html> <html> <head> <meta charset="utf-8" ...
- React使用jquery方式动态获取数据
好久没写react了,今天有空写一下来react实现实时请求数据,并刷新数据的小demo. 首先我还是选择了jquery方式中自带的ajax获取数据,首先要引用所需的js包 接下来要写一个自定义的js ...
- vue 中使用 AJAX获取数据的方法
在VUE开发时,数据可以使用jquery和vue-resource来获取数据.在获取数据时,一定需要给一个数据初始值. 看下例: <script type="text/javascri ...
- Thymeleaf+SpringMVC,如何从模板中获取数据
Thymeleaf+SpringMVC,如何从模板中获取数据 在一个典型的SpringMVC应用中,带@Controller注解的类负责准备数据模型Map的数据和选择一个视图进行渲染.这个模型Map对 ...
随机推荐
- ISP图像调试工程师——自动对焦(熟悉3A算法)
https://wenku.baidu.com/view/40ec4a14fc4ffe473368ab96.html
- db2 v9.5迁移至v10.5,及遇重名节点数据库无法创建db的解决办法
同系统同版本可以使用备份恢复,本文前提是不同系统不同版本,使用db2move命令. 1.db2move db db_name export 此处注意,先建个目录放文件,因为文件比较多,如果上来直接ex ...
- [PHP]如何使用Mobile_Detect来判断访问网站的设备:安卓,平板,电脑
Mobile_Detect 是一个轻量级的开源移动设备(手机)检测的 PHP Class, 它使用 User-Agent 中的字符串,并结合 HTTP Header,来检测移动设备环境. 这个设备检测 ...
- 删除其他硬盘的Windows文件夹
删除其他硬盘的Windows文件夹 学习了:https://blog.csdn.net/drbing/article/details/50881461 有效果,必须先改文件夹的所属,然后才能修改权限: ...
- 【ACM】How many prime numbers
http://acm.hdu.edu.cn/game/entry/problem/show.php?chapterid=2§ionid=1&problemid=2 #inclu ...
- 【转】Android之Adapter用法总结
1.概念 Adapter是连接后端数据和前端显示的适配器接口,是数据和UI(View)之间一个重要的纽带.在常见的View(ListView,GridView)等地方都需要用到Adapter.如下图直 ...
- Android 珍藏(三)
1.Android判断是Pad或者手机 public boolean isTabletDevice() { TelephonyManager telephony = (TelephonyManager ...
- SQL如何将EXCEL导入到SQL数据库
1 新建一个EXCEL工作表,注意默认有三个工作簿,我们只在Sheet1中创建几个字段并存储若干值保存为TEST.xls 2运行Excel to MySQL软件,注意Sourece和Destinati ...
- Sun公司开源游戏服务器
http://www.360doc.com/content/11/0307/12/2902158_98866885.shtml http://www.cnblogs.com/daidu/archive ...
- webDriver API——第6部分Locate elements By
These are the attributes which can be used to locate elements. See the Locating Elements chapter for ...