开发者

Flex4: Using httpService in consecutive function calls

I have this button:

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

and this click event handler:

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

the downloadData function looks like this:

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开发者_StackOverflow 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);
    }
}

The problem is, all calls are ignored, except for the first one. Is there any "queuing" mechanism which would allow all calls to be made?

Thank you.


You need to chain your asynchronous calls. See these 2 blog posts for implementations :

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

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


I will rather use observer pattern. The easiest way.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜