Flex与java通信
Flex与java通信,要用json传输数据,试验了很多,总是不成功能给我一个简单详细的例子吗,最好是视频 Flex与java通信 json传输数据
[解决办法]
视频木有,我大致把我们项目中的代码整理了一下:
var service:HTTPService = new HTTPService();
service.showBusyCursor = true;
service.method = "POST";
service.addEventListener(FaultEvent.FAULT, faultListener);
service.addEventListener(ResultEvent.RESULT, resultListener);
service.url = "/Project/service/Some.jsp";
var parameters:URLVariables = new URLVariables();
parameters.id = 123;
parameters.name = "abc";
service.send(parameters);
public static function onServiceFault(event:FaultEvent):void {
Alert.show(event.fault.message);
}
public static function onServiceResult(event:ResultEvent):void {
var response:Object = JSON.parse(event.result.toString());
...
}