title: Trying to understand the AsyncToken in Flex/Actionscript
body: <p>I am trying to understand the way the AsyncToken works in actionscript. How can I call a remote service and ensure that a specific parameter is available in the result or fault event functions? I think it is the async functionality I want to use.</p>
  
  <p>The following code will hopefully explain what I am trying to do. Feel free to modify the code block as your explanation.</p>
  
  <p>Thanks.</p>
  
  <pre><code>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?
  } 
  </code></pre>
  
  <p>An edit to make this question more clear:</p>
  
  <p>Assume I make the following method call somewhere in my code:</p>
  
  <pre><code>testSerivceCall(personObject, "LoginCommand");
  </code></pre>
  
  <p>How do I get access to the actual string "LoginCommand" inside the _handleTestResult function block?</p>
  
  <p>The reason I want to do this is because I want to dynamically call back certain functions and hand off the result data to specific commands that I know ahead of time when I am making the service call.</p>
  
  <p>I am just having a time grokking the AsyncToken syntax and functionality.</p>