开发者

Passing parameters between functions and result handlers

开发者 https://www.devze.com 2023-01-07 02:51 出处:网络
I have a function fooA(valueA1, valueA2) which calls web method myWSA(). Upon reeiving the result, it invokes a result handler which inturn calls another web service开发者_运维问答 myWSB(value2). I wa

I have a function fooA(valueA1, valueA2) which calls web method myWSA(). Upon reeiving the result, it invokes a result handler which inturn calls another web service开发者_运维问答 myWSB(value2). I want to know how I can pass/access this value2 into foo2. These values: value1 and value2 are dependent on the button clicled.

private function fooA(valueA1:int, valueA2:int){
     callResponder.token = myWSA(valueA1);
}

private function myWSA_resultHandler(event:ResultEvent ) {
     myWSB(value2); //----------> I want to use the parameter, value2, passed in fooA here.

}


<fx:Declarations>
<s:WebService id = "myWebService"
                      wsdl = "http://MyWebService?wsdl"
                      fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)">
            <s:operation name = "myWSA"
                         result= "myWSA_resultHandler(event)"/>

</s:WebService>
<s:CallResponder id = "callResponder" />
</fx:Declarations>

<s:Button id = "button1"
          label="Button1"
       click = "fooA(val1, val2)"/>
<s:Button id = "button2"
          label="Button2"
       click = "fooA(val3, val4)"/>


You can't access an argument from one method inside another method. Go back to the source and access the original value.

If your able to assume that Val1 and val2 won't change between the start of the first call and the second call, just access them normally using this.val1 .

If you want to assume the values may change, or are call specific, then you'll want to store the values at the time of the first call, under the assumption that they may change you'll need to write a mechanism to keep track of ongoing calls and their relevant associated properties.

I question what you're trying to accomplish, though. Wouldn't it be better to wrap up web service 1 and web service 2 into the same call?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号