云自无心水自闲

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

用HttpService加载发送Xml数据

Posted on 2006-03-01 01:18 云自无心水自闲 阅读(570) 评论(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)">




只有注册用户登录后才能发表评论。


网站导航: