1

我有这个按钮:

<s:Button includeIn="MeniuPrincipal" label="Descarcare Date" click="downloadLmData(event)"/>

这个点击事件处理程序:

protected function downloadLmData(event:MouseEvent):void
{
    downloadData('competenta', 'competente');
    downloadData('localitate', 'localitati');
}

downloadData 函数如下所示:

private function downloadData(item:String, items:String):void 
{
    try {
        var colVar:String   = 'col' + cappitalize(items);

        this.status = "Descarcare date in curs...";

        this[colVar] = null;

        var service:HTTPService = new HTTPService();
        service.url = serverUrl + items + '/xml';
        service.resultFormat = "xml";
        service.method = "GET";
        service.addEventListener(ResultEvent.RESULT, addArguments(downloadDataComplete, [item, items]));
        service.send();
    } catch (error:Error) {
        errorHandler.defaultErrorHandler(error);
    }
}

问题是,所有呼叫都被忽略了,除了第一个。是否有任何“排队”机制允许进行所有呼叫?

谢谢你。

4

2 回答 2

1

您需要链接异步调用。有关实现,请参阅以下 2 篇博客文章:

http://kuwamoto.org/2006/05/16/dealing-with-asynchronous-events-part-1/

http://kuwamoto.org/2006/05/16/dealing-with-asynchronous-events-part-2/

于 2011-03-15T17:58:36.693 回答
0

我宁愿使用观察者模式。最简单的方法。

于 2011-03-16T06:12:19.783 回答