云自无心水自闲

天平山上白云泉,云自无心水自闲。何必奔冲山下去,更添波浪向人间!
posts - 131, comments - 201, trackbacks - 0, articles - 6
  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

用HttpService加载发送Xml数据

Posted on 2006-03-01 01:18 云自无心水自闲 阅读(208) 评论(0)  编辑  收藏 所属分类: Flex

I've been looking at sending and receiving data asyncronously using Flex's HTTPService and native Flash data loading capabilities.
One thing that tripped me up with that xml.load() was an asyscronous data call -- which means you cannot use the result/return object until it is completly loaded. One way around this is to use the AS delegate to invoke a function which uses the result. Below is some code.

http://www.macromedia.com/2003/mxml">

function LoadRequest() {
  var myXML = new XML();
  myXML.ignoreWhite = true;
  myXML.load ("tree.xml");
  myXML.onLoad = mx.utils.Delegate.create(this, function() { myService.send(myXML) });
}

function ProcResult(event) {
  txtDebug.text = event.result;
}

function ProcFault(errorString, code) {
  txtIssuerList.text = errorString + " " + code ;
}

http://localhost:8700/flex/servlet/test.MyServletPrintln" contentType="application/xml" method="post" id="myService"
fault="ProcFault(event.fault.faultstring, event.fault.faultcode)" result="ProcResult(event)">




标题  
姓名  
主页
验证码 *  
内容(请不要发表任何与政治相关的内容)  
  登录  使用高级评论  新用户注册  返回页首  恢复上次提交