I would like to reuse a s:HTTPService
component if possible. I am having trouble understanding how to pass a parameter to the service call so the result function can be changed.
For example,
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
You can not pass a parameter to the HTTPService but you can can change the handler function for different requests. This is a sample
<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
}
Then You can call functOne() and functTwo() as you like