import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.rpc.http.HTTPService;
import mx.controls.Alert;
import com.adobe.serialization.json.JSON;

private var httpService:HTTPService = new HTTPService();
protected function button1_clickHandler(event:MouseEvent):void
{

httpService.url="http://localhost:8080/trf/xt/traffic";
httpService.method="POST";                         //重要,默认GET
httpService.contentType="application/json";    //重要,默认XML
httpService.showBusyCursor = true;
httpService.addEventListener(ResultEvent.RESULT,getResult);
httpService.addEventListener(FaultEvent.FAULT,getFailure);

var sub:Object= new Object();
sub.id=1;
var para:Object =new Object();
para.cmd="findXhjById";
para.token="token";
para.params= sub;
var jstr:Object=com.adobe.serialization.json.JSON.encode(para); //重要
httpService.send(jstr);

}

private function getResult(event:ResultEvent){

Alert.show("-----------success----------");
var obj:Object= com.adobe.serialization.json.JSON.decode(event.message.body.toString());
Alert.show("address:" + obj.detail.address);

}

private function getFailure(event:FaultEvent){
     Alert.show("-----------Failure----------");
}

Flex HTTPService json的更多相关文章

  1. Flex+Struts2+JSON实现Flex和后台的HTTP Service请求

    http://www.fengfly.com/plus/view-191093-1.html Flex+Struts2+JSON的后台代码我在这就不多说了.不懂得请看我写的上一篇文章<Strut ...

  2. Flex httpservice返回值类型和处理 (转)

    这两天在考虑flex与后端java服务交互的问题.在采用BlazeDS的Remote Object方式,还是传统的http service方式之间徘徊了一段时间 采用BlazeDS的Remote Ob ...

  3. Flex编码随笔

    1.CSS定义最好放在application里面. 2.数据源是数组数据时,最好把数组转换为ArrayCollection. 3.List.CheckBox等控件的HttpService Params ...

  4. Flex远程访问获取数据--HTTPService

    编写service类: package services { import com.adobe.serialization.json.JSON; import log.LogUtil; import ...

  5. Flex之HTTPService组件调用

    1.采用<s:HTTPService>标签来实现: <?xml version="1.0" encoding="utf-8"?>< ...

  6. 【Flex】读取本地XML,然后XML数据转成JSON数据

    干了一年H5,最近被要求写编辑器,Electron等级还不够,写不了,只有重新拿起as3,用flex,最近写到数据表编辑模块,有这部分功能,基本完成 . package utils { /** * 模 ...

  7. Flex与Java通信之HttpService

    flashbuilder4.6.myeclipse10 参考:http://www.cnblogs.com/lovemoon714/archive/2012/05/25/2517684.html 1. ...

  8. flex 遍历Object或者JSON对象内容的实现代码

    private function init():void { //新建对象 var obj:Object = new Object(); //增加key-value obj["name&qu ...

  9. 基于Flex的HTTPService(GET和POST)

    一.基于GET的HTTPService: <?xml version="1.0" encoding="utf-8"?><mx:Applicat ...

随机推荐

  1. 移动网页 -- CSS布局

    1.多栏结构 column-count column-width column:120px 3: column-gap:2em: column-rule:2px dotted gray: 跨越以及打断 ...

  2. 2.2 代码块--delphi 写日志模块

    //2.2 代码块--写日志 //调用例句如:LogMsg('FTP上传线程终止',False,true); procedure LogMsg(AMsg: string; const blnIsErr ...

  3. Fibonacci

    20145218 <Java程序设计>第01次实验报告 实验内容 简单使用命令行 撰写简单的Hello.java程序,使用命令行编译.运行.编译命令javac -d Hello.java, ...

  4. Linux中cp覆盖不提示

    cp覆盖时,无论加什么参数-f之类的还是提示是否覆盖,这在大量cp覆盖操作的时候是不能忍受的. 1. 把a目录下的文件复制到b目录 cp –r a/* b 2. 执行上面的命令时,b存在的每个文件都会 ...

  5. 在 Chrome 中调试 Android 浏览器

    最近需要使用 Chrome Developer Tools 调试 Android 浏览器,但是官方指南并不是很好使,经过一番折腾,终于调试成功了,在此把经验分享给需要的朋友. Chrome Devel ...

  6. iOS Aspect Fit,Aspect Fill,Scale To Fill

    Scale:拉伸图片,图片变形. Aspect:图片长宽的保持比例,图片不变形. Aspect Fill(常用):图像充满容器.以长宽中小的参数为限制. Aspect Fit:图像在容器中完整显示.以 ...

  7. 旧版API的TextInputFormat源码分析

    TextInputFormat类 package org.apache.hadoop.mapred; import java.io.*; import org.apache.hadoop.fs.*; ...

  8. Qt搭建多线程Server

    起因是MySQL在Android上没有驱动.也就是说,移动端想要访问远程数据库,必须通过一台(或多台)PC进行中转. 中转PC作为Server,接受来自移动端Socket访问数据库的要求,Server ...

  9. Android---表格布局

    最简单的表格布局

  10. 跨集群 distcp命令

    两个集群之间做数据同步,而且两个集群之间的版本不一致,这个时候使用的是hftp协议或者webhdfs协议! 如果试图在两个运行着不同HDFS版本的集群上使用distcp命令来复制数据并使用hdfs协议 ...