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

后端 未结 3 365
无人及你
无人及你 2021-01-21 05:37

All,

I\'m working on an Flash/AS3 project that makes numerous URLLoader.load() requests.

Should I queue them so that there\'s only a single open request at any t

相关标签:
3条回答
  • 2021-01-21 05:42

    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

    0 讨论(0)
  • 2021-01-21 05:51

    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.

    0 讨论(0)
  • 2021-01-21 06:03

    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.

    0 讨论(0)
提交回复
热议问题