Skip to main content
Participating Frequently
November 27, 2008
Question

Can't use addAsync and AsyncResponder together

  • November 27, 2008
  • 1 reply
  • 1721 views
I have the following code in my test case:

var token:AsyncToken = transfer.save(currentChild);

token.addResponder(new AsyncResponder(
addAsync(
function (result:ResultEvent, token:Object=null):void
{
onSaveChild(result.result as Child);
}, TIMEOUT),
function(error:Object, token:Object=null):void {}
)
);

When this is run, this gives me the following error in my debug:

ArgumentError: Error #1063: Argument count mismatch on flexunit.framework::AsyncTestHelper/handleEvent(). Expected 1, got 2.
at mx.rpc::AsyncResponder/result()
at mx.rpc::AsyncToken/http://www.adobe.com/2006/flex/mx/internal::applyResult()
at mx.rpc.events::ResultEvent/http://www.adobe.com/2006/flex/mx/internal::callTokenResponders()
at mx.rpc::AbstractOperation/http://www.adobe.com/2006/flex/mx/internal::dispatchRpcEvent()
at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::resultHandler()
at mx.rpc::Responder/result()
at mx.rpc::AsyncRequest/acknowledge()
at NetConnectionMessageResponder/resultHandler()
at mx.messaging::MessageResponder/result()

Looking at the addAsync() code, this is not surprising, as it returns a method with only 1 argument of type Event.

Is there a different way that I can be using a AsyncResponder, or should I just avoid doing this sort of implementation style all together with FlexUnit?

(Or should I submit a bug?)

Thanks in advance.
This topic has been closed for replies.

1 reply

Participating Frequently
November 28, 2008
To get around this, I wrote my own, simple AsyncResponder, like so, and it seems to be working well:

package transfer.tests
{
import mx.rpc.IResponder;

public class ResultAsyncResponder implements IResponder
{
private var _result:Function;

public function ResultAsyncResponder(result:Function)
{
_result = result;
}

public function result(data:Object):void
{
_result(data);
}

/**
* Does nothing
*/
public function fault(info:Object):void
{
}
}
}