This content has been marked as final. Show 4 replies
This no doubt has to do with the fact that Flex is asynchronous. I would have the ac.addItemAt(image, i) in the loadComplete method.
Greg, good idea, but I tried that also. Unfortunately, when I do add the ac.addItemAt(image, i) into the loadComplete function it errors out of bounds because the .load call loads each of the files in succession without waiting for the loader to be done each time. So I get one instance of the array, but not all 5. So then I tried making the counter a module level variable and adding an if statement to the loadComplete function to check and see if the i value was less than the array.length of my input array and unfortunately that didn't work either.
I am just learning this language, but there seems to have to be a way to deal with these instances. I don't know all the tools available but one that seems promising is the following:
create an event
var e:Event = new Event("watchTheStupidLoader");
take out the loop completely and check the counter with a function;
change the location of the array and increment the counter within that function, passing the next url as a return. I guess it would be a way to post-test the loop...
any comment on trying it that way or a tool I'm overlooking?
Your approach seems reasonable.
I just thought I'd give a follow up on how I figured out this problem. Of course, this may not be the best solution, so if anyone wants to chime in and tell me how it should be done, please by all means...
I removed the loop completely and rewrote the loadImage function with a new progressEvent handler. And as Greg suggested added the ac.adItem() call to the loadComplete function.