# Array inside a function

**URL:** <https://forum.kirupa.com/t/array-inside-a-function/104169>\
**Category:** Uncategorized\
**Created:** [March 13, 2004, 1:02am UTC](https://forum.kirupa.com/t/array-inside-a-function/104169 "2004-03-13T01:02:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![SuperFunHappyGy](https://avatars.discourse-cdn.com/v4/letter/s/ecc23a/32.png) [@SuperFunHappyGy](https://forum.kirupa.com/u/SuperFunHappyGy)\
**Post date:** [March 13, 2004, 1:02am UTC](https://forum.kirupa.com/t/array-inside-a-function/104169/1 "2004-03-13T01:02:24Z")

</div>

Hi everyone,

I am having a hard time trying to get this to work.

On my main timeline, I create a new array called aEventData:

aEventData = new Array();

On the next frame, I loop through data pulled from ColdFusion. I am trying to put the data into an array so that I can reference it later based on it’s position. My function to do this looks like so:

function eventDataQuery\_Result ( result ){  
// for each record in the recordset…  
for (a=0;a\<result.getLength();a++){  
// Use the record variable to refer to the current row of the recordset  
var record = result.getItemAt(a);  
//Fill our array with data from the event  
\_root[aEventData[record.eventDate]] = record.eventDesc;  
};  
}

This doesn’t work. I don’t know how to properly reference the array on the timeline. I also tried:  
\_root[(aEventData[record.eventDate])] = record.eventDesc;  
and  
\_root.aEventData[record.eventDate] = record.eventDesc;  
(I knew this one wouldn’t work but I had to try.)

If I use aEventData[record.eventDate] = record.eventDesc;  
and then trace the value from within my function, it works okay, but it doesn’t set the value in the array on my main timeline. Can anyone explain how I can reference and set values in my array from within the function?

Thanks.
