gpt4 book ai didi

actionscript-3 - ActionScript 3 AsyncToken 实现

转载 作者:行者123 更新时间:2023-12-01 04:22:00 26 4
gpt4 key购买 nike

寻找有关如何实现返回 AsyncToken 的方法的示例或文档链接。

请注意,这与使用/使用返回 AsyncToken 的方法无关!我希望自己编写这样的方法。

最佳答案

实现一个返回 AsyncToken 的方法很简单:

function doStuffLater():AsyncToken {
var token:AsyncToken = new AsyncToken(null);

// This method will randomly call the responder's 'result' or 'fault'
// handler.
function doStuff() {
var response:String = (Math.random() > 0.5)? "result" : "fault";
for each (responder:IResponder in (token.responders || [])) {
// rememeber: this is equivilent to
// responder.result(...) or responder.fault(...)
responder[response]("Got a result!");
}
}

setTimeout(doStuff, 1000);

return token;
}

请注意,您实际上不能使用 applyResultapplyFault方法,因为它们向响应者传递了 Event ,当响应者除了结果或故障对象。

关于actionscript-3 - ActionScript 3 AsyncToken 实现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1052858/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com