1.設置數據源(動態傳遞參數):url
<s:HTTPServiceid="httpServiceSend" fault="httpServiceSend_faultHandler(event)" result="httpServiceSend_resultHandler(event)" useProxy="false"> <s:request> <id>{transformationId}</id> <step>{step}</step> <runFlag>{runFlag}</runFlag> <fileName>{fileName}</fileName> <dateFlag>{dateFlag}</dateFlag> </s:request> </s:HTTPService>
2.設置出現異常的方法:code
protected function httpServiceSend_faultHandler(event:FaultEvent):void { Alert.show(event.fault.messageasString, "提示"); }
3.設置回調的方法:orm
protected function httpServiceSend_resultHandler(event:ResultEvent):void { varresult:String = event.resultasString; if(result == "SUCCESS"){ Alert.show( "操做成功!", "提示"); } else{ Alert.show("出現錯誤!", "提示"); } }
4.動態調用數據源提交數據:xml
private function sendData(event:MouseEvent):void{ dateFlag = newDate().toString(); method = "getData"; httpServiceSend.url = "http://localhost:8080/FlexDataServer/action/data.action"; httpServiceSend.send(); }