Flash/AS3 - is there a limit to the number of simultaneous URLLoader.load() requests?

拈花ヽ惹草 提交于 2019-12-01 21:10:00

I ran into this problem ages ago when I was trying to load a ton of images. They were all local, so I just queued them up with the Loader. Queue hours debugging why images were null :S

I'm not sure if the limit is mentionned anywhere, but I found (if memory serves) around 30 was giving me problems. After that and I think it would reuse old connections: so if you have 100 load() calls, only the last 30 or so would be loaded.

Normally I queue up about 10 at a time, then load in the rest as they get completed. There's no real problem with multiple connections - though they will start to take up CPU power etc.

If you want to just ignore this, check out something like BulkLoader: http://code.google.com/p/bulk-loader/ which was created for this

I don't know if there is any hard limit on this, but 5 simultaneous requests sounds quite reasonable. I know that most browsers use like 6 simultaneous connections, and probably that is the limit for Flash too.

I would use something like 5 loaders, and queue all loading transactions that go beyond that.

This question was long ago. I came here from Google but thank you for the answers.

Things might have changed. I just test reusing URLLoader.load on Flex 4.6 and AS 3.

There's a tricky and undocumented limit here. The loader can be reused but only the last request got issued in once of callback.

ex.

timer:Timer = new Timer(5000);
timer.addEventListener(TimerEvent.TIMER, timerHandle);
timer.start();
var loader:URLLoader = new URLLoader(); // and need to add listeners for response

function timerHandle(e:TimerEvent):void {
    loader.load(certainURLRequest);
}

this works well. But the way below doesn't.

function timerHandle(e:TimerEvent):void {
    loader.load(firstURLRequest); // this request didn't get issued
    loader.load(secondURLRequest); // this request got sent
}

I dont' know the internals. This might relate to the single-thread EventLoop way of ActionScript, where the request will be processed after returning from the call back and the last one overwrites the previous. It is all my guess out.

Hope this helps the followers coming here.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!