Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 786435
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T21:02:27+00:00 2026-05-14T21:02:27+00:00

As a followup to the question, How to get associated URLRequest from Event.COMPLETE fired

  • 0

As a followup to the question, How to get associated URLRequest from Event.COMPLETE fired by URLLoader, how can I make the function work for loader object in a loop?

Here is my existing (rough) code; I always get the mylabel from the last element of the array.

var _loader = new Loader(); 
for (j = 0; j < 5; j++) {
    //mylabel variable is correct setup in the loop
    _loader.contentLoaderInfo.addEventListener(Event.COMPLETE, function(e:Event):void {
        doneLoad(e, mylabel);
    });

    _loader.load(new URLRequest(encodeURI(recAC[j].url)));

}//for loop
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T21:02:27+00:00Added an answer on May 14, 2026 at 9:02 pm

    As per the comments above, this won’t work because:

    1) You’re just adding the same event listener 5 times to the loader.
    2) You’re just reseting your same loader object 5 times.

    The final output will just be as though you only called it the last time.

    There are a variety of ways to address this – loading stuff asynchronously is one of the great mindfucks of learning to code – but the simplest way is probably just to create five separate loaders.

    I’d do something like this:

    var loaders:Array = [];
    var labels:Array = ["label1", "label2", "label3", "label4", "label5"];
    for (var j:int = 0; j < 5; j++) {
    loaders[j] = new Loader();
    loaders[j].contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);
    loaders[j].load(new URLRequest(encodeURI(recAC[j].url)));
    }
    
    function completeHandler(e:Event):void {
    doneLoad(e.currentTarget, labels[loaders.indexOf(e.currentTarget)]);
    }
    

    The confusing part is finding a good way to keep track of which load is associated with which label etc, since in theory your loads can finish in any order. That’s why I’ve got a separate label array there, and then you just match up the desired label with the loader that just finished loading.

    I hope that helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A followup question to Get all text between tags with preg_match_all() or better function?
This is a followup to this SO question: How do I make a collapsible
A followup to this previous question: Current code: var query = from b in
This is a followup question of How to encode characters from Oracle to Xml?
This is a followup to my previous question. Parsing file names from a character
This is a followup question to one I previously asked: start-program-if-not-already-running-in-java I didn't get
this is actually a followup from a previous question but it contains different information
This is a followup question to my other widget-related question . I'd like to
This is a followup question to my other question : Run bat file in
As a followup to this question , is it possible to write a single

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.