如果可能,我想重用s:HTTPService
组件。我无法理解如何将参数传递给服务调用,因此可以更改结果函数。
例如,
functOne(), HTTPService result = "FunctOneRtn(event)"
functTwo(), HTTPService result = "FunctTwoRtn(event)"
flex 4.6
<fx:Declarations>
<s:HTTPService id="myCall" url="http://myUrl.com/"
useProxy="false" method="POST" result=funct***Rtn(event) >
</s:HTTPService>
</fx:Declarations>
<fx:Script>
<![CDATA[
import mx.rpc.events.ResultEvent;
private function functOne() :void
{
var params:Object = new Object();
/* call FuntOneRtn */
myCall.send(params);
}
private function functTwo() :void
{
var params:Object = new Object();
/* call FuntTwoRtn */
myCall.send(params);
}
public function FunctOneRtn(event:ResultEvent) : void{
// Do Some Stuff
}
public function FunctTwoRtn(event:ResultEvent) : void{
// Do Some Stuff
}
]]>
</fx:Script>
thx Art
答案 0 :(得分:1)
您无法将参数传递给HTTPService,但您可以更改不同请求的处理函数。这是一个样本
<fx:Declarations>
<s:HTTPService id="myCall" url="http://myUrl.com/"
useProxy="false" method="POST">
</s:HTTPService>
</fx:Declarations>
private function functOne():void
{
myCall.addEventListener("result",FunctOneRtn);
}
private function functTwo():void
{
mycall.removeEventListner("result",FunctOneRtn);
myCall.addEventListener("result",FunctTwoRtn);
}
private function FunctOneRtn(event:ResultEvent)
{
//handle function one result
}
private function FunctTwoRtn(event:ResultEvent)
{
//handle function two result
}
然后您可以根据需要调用functOne()和functTwo()
答案 1 :(得分:0)
我相信我们只有一个ResultEvent函数,你必须编写逻辑来区分你从ResultEvent获得的第一次和第二次调用的结果。