AsyncToken이 actionscript에서 작동하는 방식을 이해하려고합니다. 원격 서비스를 호출하고 특정 매개 변수가 결과 또는 오류 이벤트 함수에서 사용 가능한지 확인하려면 어떻게해야합니까? 나는 그것이 사용하고 싶은 비동기 기능이라고 생각한다.플렉스/액션 스크립트에서 AsyncToken을 이해하려고 시도했습니다.
다음 코드는 내가하려고하는 바를 설명합니다. 코드 블록을 설명대로 수정하십시오.
감사합니다. 에디트
public function testSerivceCall(data:Object, callBackCommand:String):void
{
// Assume callBackCommand == "FOO";
// How can I pass in callBackCommand as a parameter to the result or fault events?
// How do I create an async token here?
var remoteObject:RemoteObject;
remoteObject = new RemoteObject();
remoteObject.destination = "zend";
remoteObject.source = "MyService";
remoteObject.endpoint = "http://example.com/service";
remoteObject.test.addEventListener(ResultEvent.RESULT, _handleTestResult);
remoteObject.test.addEventListener(FaultEvent.FAULT, _handleTestFault);
remoteObject.test(data);
}
private function _handleTestResult(event:ResultEvent) : void
{
// How do I get the async token value?
// How can I get the value of callBackCommand in this code block?
if (callBackCommand == "FOO")
{
// do something related to "FOO"
}
else
{
// do something else with the result event
}
}
private function _handleTestFault(event:FaultEvent) : void
{
// How do I get the async token value?
// How can I get the value of callBackCommand in this code block?
}
이 질문을 더 명확하게하기 :
내가 내 코드 어딘가에 다음과 같은 메소드 호출을 가정 : 나는 "실제 문자열에 접근하려면 어떻게
testSerivceCall(personObject, "LoginCommand");
을 LoginCommand "_handleTestResult 함수 블록 안에 있습니까? 나는 동적으로 특정 기능을 다시 호출하고 I가 서비스 호출을하고 때를 미리 알고 특정 명령에 결과 데이터를 손에 원하기 때문에
나는이 작업을 수행 할 수있는 이유입니다.
저는 AsyncToken 구문과 기능을 익히는 데 시간을 보내고 있습니다. 내가 제대로 질문을 읽고 있어요 경우
좋아,이 말은 고마워! 여전히 클로저에 대한 핸들을 얻는 중입니다. –