I have created a class file with 2 functions one to load an xml file and the other to parse the file and push the values into an array. My problem is that I can’t access this array inside another function unless pass the array as a parameter or the main timeline. Below is the class file I’m using:
import mx.utils.Delegate;
class XmlTest
{
var TechIIIArray:Array = new Array();
var TechIII:XML;
function XMLContentLoader(arr:Array):Array{
TechIII = new XML();
TechIII.ignoreWhite = true;
TechIII.onLoad = Delegate.create(this, onLoadEvent);
TechIII.load("techIII.xml");
trace ("This is from the class file --->"+TechIIIArray);
return TechIIIArray;
}
function onLoadEvent(success:Boolean)
{
if (success)
{
var i=0;
while(TechIII.firstChild.childNodes*.childNodes[0].firstChild.nodeValue != undefined)
{
var rarity:Number = TechIII.firstChild.childNodes*.childNodes[0].firstChild.nodeValue;
var itemname:String = TechIII.firstChild.childNodes*.childNodes[1].firstChild.nodeValue;
var price:Number = TechIII.firstChild.childNodes*.childNodes[2].firstChild.nodeValue;
var tech:String = TechIII.firstChild.childNodes*.childNodes[3].firstChild.nodeValue;
var complexity:String = TechIII.firstChild.childNodes*.childNodes[4].firstChild.nodeValue;
var book:String = TechIII.firstChild.childNodes*.childNodes[5].firstChild.nodeValue;
var page:String = TechIII.firstChild.childNodes*.childNodes[6].firstChild.nodeValue;
i++;
TechIIIArray.push([rarity,itemname,price,tech,complexity,book,page]);
}
trace("Tech III Array--> "+TechIIIArray);
}
else
{
trace("file not loaded!");
}
}
function getArray():Array{
trace("This is the Tech III Array returned from the getArray ->"+TechIIIArray)
return TechIIIArray;
}
}
What I would like to do is pass the array to another function in the class file. This function would loop through the array and push certain values into an array that would be returned to the main timeline so I can using them.
Not sure how to do this hopefully one of you AS guru can help me out.
-Fred