1

如果可能的话,我想重用一个s:HTTPService组件。我无法理解如何将参数传递给服务调用,以便可以更改结果函数。

例如,

functOne(), HTTPService result = "FunctOneRtn(event)"
functTwo(), HTTPService result = "FunctTwoRtn(event)"

弹性 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>

谢谢艺术

4

2 回答 2

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()

于 2012-08-14T08:25:35.533 回答
0

我相信我们将只有一个 ResultEvent 函数,您必须编写逻辑来区分第一次和第二次调用从 ResultEvent 获得的结果。

于 2012-08-14T06:25:08.000 回答