# \[AS2\] - Problem with code not returning an array

**URL:** <https://forum.kirupa.com/t/as2-problem-with-code-not-returning-an-array/198979>\
**Category:** flash\
**Created:** [August 30, 2006, 7:03am UTC](https://forum.kirupa.com/t/as2-problem-with-code-not-returning-an-array/198979 "2006-08-30T07:03:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![hued](https://avatars.discourse-cdn.com/v4/letter/h/94ad74/32.png) [@hued](https://forum.kirupa.com/u/hued)\
**Post date:** [August 30, 2006, 7:03am UTC](https://forum.kirupa.com/t/as2-problem-with-code-not-returning-an-array/198979/1 "2006-08-30T07:03:38Z")

</div>

Right now, i have this code that’s supposed to return the an array that holds the values that were contained within an XML node.

```auto

function gatherXmlData():Array {
  var calendarData:XML = new XML();
  var currentCalendarData:Array = new Array();
  var dateInfo_array:Array = new Array();
  var inc:Number = new Number(0);
          
  calendarData.load("http://localhost/curves/calendar/admin/calendar.xml");
  calendarData.ignoreWhite = true;
  calendarData.onLoad = function (loaded:Boolean) {    
     if (calendarData.loaded) {
        currentCalendarData = calendarData.firstChild.childNodes;
        for (inc = 0; inc < currentCalendarData.length; inc++) {
          dateInfo_array[inc] = currentCalendarData[inc].firstChild.firstChild.nodeValue.split("-", 3);
        }
     }
  }
  return dateInfo_array;
}

```

for some reason, the code won’t return anything. the output just says “undefined”. Would a good workaround consist of putting the return function within a setInterval method?
