Flex4:在连续函数调用中使用httpService

时间:2011-03-15 16:49:59

标签: flex queue httpservice

我有这个按钮:

<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);
    }
}

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

谢谢。

2 个答案:

答案 0 :(得分:1)

答案 1 :(得分:0)

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