# My array is empty

**URL:** <https://forum.kirupa.com/t/my-array-is-empty/286596>\
**Category:** flash\
**Created:** [April 17, 2009, 2:38pm UTC](https://forum.kirupa.com/t/my-array-is-empty/286596 "2009-04-17T14:38:40Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![vanderwaal](https://avatars.discourse-cdn.com/v4/letter/v/b2d939/32.png) [@vanderwaal](https://forum.kirupa.com/u/vanderwaal)\
**Post date:** [April 17, 2009, 2:38pm UTC](https://forum.kirupa.com/t/my-array-is-empty/286596/1 "2009-04-17T14:38:40Z")

</div>

i know it has to be something simple but i’ve been staring at it too long now to see what it is. can someone tell me why my array is empty when i trace it at the end of the script? it’s really simple code. should work fine but when i trace out my array at the end it’s empty. if i trace it inside the “textLoaded” function it’s there. any help would be greatly appreciated. pay no attention to the xmlLoader and such. it is for future functionality and to provide the length for the loop.

```auto
var xmlLoader:URLLoader = new URLLoader();
var xmlData:XML = new XML();
xmlLoader.addEventListener(Event.COMPLETE, LoadXML);
xmlLoader.load(new URLRequest("media.xml"));

var i:int;
var numbersArray:Array = new Array();

function LoadXML(e:Event):void {
    xmlData = new XML(xmlLoader.data);

    for (i = 0; i < xmlData.item.length(); i++) {
        var countFile:String = "../song" + i + "play.txt";
        var countloader:URLLoader = new URLLoader();
        countloader.addEventListener(Event.COMPLETE, textLoaded);
        countloader.load(new URLRequest(countFile));

        function textLoaded(event:Event):void {
            numbersArray.push(event.target.data);
        }

    }

}
trace(numbersArray);

```
