# Arrays, loops, AddEventListeners Problem

**URL:** <https://forum.kirupa.com/t/arrays-loops-addeventlisteners-problem/246922>\
**Category:** flash\
**Created:** [December 16, 2007, 5:19pm UTC](https://forum.kirupa.com/t/arrays-loops-addeventlisteners-problem/246922 "2007-12-16T17:19:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![nopudac](https://avatars.discourse-cdn.com/v4/letter/n/48db29/32.png) [@nopudac](https://forum.kirupa.com/u/nopudac)\
**Post date:** [December 16, 2007, 5:19pm UTC](https://forum.kirupa.com/t/arrays-loops-addeventlisteners-problem/246922/1 "2007-12-16T17:19:27Z")

</div>

Hi, I’m sure this is something very dumb, but I just can’t it figure out…  
I think it’s easier to look at the code than to try to describe: (this is a part of a error free source)

…

for (var k:int=0;k\<UILoaderArray.length;k++)  
{  
trace(thumbnailPaths\_arr[k]);  
UIReq = new URLRequest(thumbnailPaths\_arr[k]);  
UILoaderArray[k].load(UIReq);  
UILoaderArray[k].addEventListener(Event.COMPLETE, TnCompleted);  
}  
}

function TnCompleted(evt:Event):void {  
trace(evt.currentTarget);

…

//////The actual length is 13, so there are 13 traces of thumbnailPaths\_arr. OKAY  
/////The problem is that I should get many COMPLETE event, but I only get one…  
anyone can explain?  
(I’ve already made it work but the code was bad with too many ?imbricated? functions)  
I’ve tried with a Array.forEach method with corresponding function, same thing, only one event occur, all links are good and verified, so they should be loading, and they are very small thumbnails (3-5k) loaded locally so… the issue is not there.

thanks a lot
