私は、AsyncTokenの動作方法をActionScriptで理解しようとしています。リモートサービスを呼び出して、特定のパラメータが結果イベント関数またはフォルトイベント関数で使用できることを確認するにはどうすればよいですか?私はそれが私が使用したい非同期機能だと思う。Flex/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関数ブロック内にありますか?
私はこれをやりたいのは、特定の関数を動的に呼び出して、結果のデータをサービスコールを呼び出す前に知っている特定のコマンドに渡したいからです。
私はちょうどAsyncTokenの構文と機能をgrokkingしています。
これは感謝しています。まだクロージャのハンドルを取得しています。 –