# Referencing an Array value globally XML

**URL:** <https://forum.kirupa.com/t/referencing-an-array-value-globally-xml/217926>\
**Category:** Uncategorized\
**Created:** [March 2, 2007, 11:04pm UTC](https://forum.kirupa.com/t/referencing-an-array-value-globally-xml/217926 "2007-03-02T23:04:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![fried](https://avatars.discourse-cdn.com/v4/letter/f/3d9bf3/32.png) [@fried](https://forum.kirupa.com/u/fried)\
**Post date:** [March 2, 2007, 11:04pm UTC](https://forum.kirupa.com/t/referencing-an-array-value-globally-xml/217926/1 "2007-03-02T23:04:31Z")

</div>

Hi guys,

I have been trying to get this right for a few days now, but I am stumped. This code runs on the first frame of my movie:

```auto

_global.headingText = new Array();
_global.captionText = new Array();
_global.contentText = new Array();
_global.photos = new Array();
var spacing:Number = 20;

var my_xml:XML = new XML();
my_xml.ignoreWhite = true;

my_xml.onLoad = function(success){
	if(success){
		checkLoad(this);
		//_global.myVar = new XML(this);
	}else{
		trace("error loading");
	}
}

my_xml.load("text.xml");

function checkLoad(xml){
		for(var i:Number = 0; i<my_xml.firstChild.childNodes.length; i++){
			//running through the XML structure to populate the arrays we created up top.
			headingText* = my_xml.firstChild.childNodes*.childNodes[0].firstChild.nodeValue;
			captionText* = my_xml.firstChild.childNodes*.childNodes[1].firstChild.nodeValue;
			contentText* = my_xml.firstChild.childNodes*.childNodes[2].firstChild.nodeValue;
			photos* = my_xml.firstChild.childNodes*.childNodes[3].firstChild.nodeValue;
			
			//trace(headingText*);
			
		}
		
		for(var z:Number = 0; z<my_xml.firstChild.childNodes.length; z++){
			duplicateMovieClip("content_mc","content"+z+"_mc",z);
			_root["content"+z+"_mc"]._x = (100*z)+650;
			content_mc.contentTxt.text = contentText*;
		}
}

```

evrything loads fine, and all is well. When i try to reference headingText\* in a movie clips timeline ie myClip’s timeline, it does not allow this. I have used \_global when creating my variables, as you can see. When in myClip’s timeline and I trace(headline) I get the three values for those specific nodes. When i try and trace(headingText\*) I get an undefined.

I have also tried this:

```auto
_global.myVar = headingText* = my_xml.firstChild.childNodes*.childNodes[0].firstChild.nodeValue;

```

but then it only traces the last node value.

What am I doing wrong, this is really getting to me…

thanks in advance.
