开发者

How to code parallel -> sequencial program in AS3

I want to develop the following program in AS3

main -> Async call A -----> join 
     |- Async call B ->|
     |- Async call C ->|

-

var xmlLoaderA:URLLoader = new URLLoader();
var xmlLoaderB:URLLoader = new URLLoader();
var xmlLoaderC:URLLoader = new URLLoader();
xmlLoaderA.load(new URLRequest("http://example.com/a.xml"));
xmlLoaderB.load(new URLRequest("http://example.com/b.xml"));
xmlLoaderC.load(new URLRequest("http://example.com/c.xml"));

xmlLoaderA.addEventListener(Event.COMPLETE, xmlLoadedA);
xmlLoaderB.addEventListener(Event.COMPLETE, xmlLoadedB);
xmlLoaderC.addEventListener(Event.COMPLETE, xmlLoadedC);

A Async call has HTTP access and join me开发者_开发知识库thod merge the data from each HTTP access. If you have a some example I'm happy.


The raix framework allows composition of asynchronous operations:

Edit: I misunderstood your async requirements. Updated to fetch all three at the same time:

Observable.forkJoin([
    Observable.urlRequest(new URLRequest("http://tempuri.org/1"))
    Observable.urlRequest(new URLRequest("http://tempuri.org/2"))
    Observable.urlRequest(new URLRequest("http://tempuri.org/3"))
])
.subscribe(function(values:Array) : void
{
    // values contains result from requests in the original order
});

Disclaimer: I am the author of raix

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜