# Accessing Array Value from Loaded MC

**URL:** <https://forum.kirupa.com/t/accessing-array-value-from-loaded-mc/249439>\
**Category:** flash\
**Created:** [January 18, 2008, 7:37pm UTC](https://forum.kirupa.com/t/accessing-array-value-from-loaded-mc/249439 "2008-01-18T19:37:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![wonker1](https://avatars.discourse-cdn.com/v4/letter/w/c0e974/32.png) [@wonker1](https://forum.kirupa.com/u/wonker1)\
**Post date:** [January 18, 2008, 7:37pm UTC](https://forum.kirupa.com/t/accessing-array-value-from-loaded-mc/249439/1 "2008-01-18T19:37:57Z")

</div>

I am creating a movie that loads data from xml files into an array. The values in the array are then accessed by a clip loaded into the main timeline.

I can trace the values in the array without an issue from the main timeline. When I store an array value to variable and trace that variable from the loaded clip I get a value back back. If I try to access the array directly from the loaded clip everything returns undefined.

MAIN TIMELINE (function called by button press):  
function arrayBuilder(jobCat){

```
var listArray:Array = new Array();
var person:Array = new Array();
var jobCode:Array = new Array();
var firstName:Array = new Array();
var lastName:Array = new Array();
var jobTitle:Array = new Array ();
var office:Array = new Array();
var clientList:Array = new Array();
var education:Array = new Array();

//Gets info for bars from XML
var xmlFile:XML = new XML();
xmlFile.ignoreWhite = true;
    if(jobCat=="da"){
    xmlFile.load("../digital_artists.xml");
    }else if(jobCat=="ae"){
        xmlFile.load("../account_execs.xml");
    }else if (jobCat=="gp"){
        xmlFile.load("../gamedayProducers.xml");
    }
    
//Store info from XML into arrays
    xmlFile.onLoad = function(success) {
    listArray = this.firstChild.childNodes;
    _global.numEmployees = listArray.length;
    
    for (i=0; i&lt;listArray.length; i++) {
        person.push(listArray*.attributes.person);
        clientList.push(listArray*.attributes.clientList);
        jobCode.push(listArray*.attributes.jobCode);
        firstName.push(listArray*.attributes.firstName);
        lastName.push(listArray*.attributes.lastName);
        jobTitle.push(listArray*.attributes.jobTitle);
        office.push(listArray*.attributes.office);
        education.push(listArray*.attributes.education);
    }
    
    //load Appropriate Nav.swf
        if(jobCat=="da"){
            _root.profileTarget.loadMovie("digitalArtists_Nav.swf");
        }else if(jobCat=="ae"){
            _root.profileTarget.loadMovie("accountExecs_Nav.swf");
        }else if (jobCat=="gp"){
            _root.profileTarget.loadMovie("gamedayProducers_Nav.swf");
        }
    }

```

}

Things that work:  
Adding “trace(firstName[1]);” to the main timeline

If a variable is created with the value of firstName[1] (i.e. FN=firstName[1]) and traced by the loaded swf with “trace(\_root.FN);” however, “trace(\_root.firstName[1]);” always returns undefined.

Any Ideas?

Thanks in Advance
