Upon parsing XML via an AS class called XMLMenu I created (an extension/modification to Senocular’s code), I want to save the root XML node/structure to use later.
Here is the relevant code:
// class var to save root node to...
private var menuNode:XMLNode;
public function XMLMenu(xmlURL:String, container:MovieClip, x:Number, y:Number) {
this.container = container;
this.x = x;
this.y = y;
menuXML = new XML();
menuXML.ignoreWhite = true;
menu = container.createEmptyMovieClip("menu", container.getNextHighestDepth());
submenu = menu.createEmptyMovieClip("submenu", menu.getNextHighestDepth());
loadXML(xmlURL);
}
public function loadXML(xmlURL:String):Void {
var menuClass:XMLMenu = this;
menuXML.onLoad = function(success) {
if (success) {
menuClass.createMenu(menuClass.getX(), menuClass.getY(), this.firstChild, true);
menuClass.menuNode = this.firstChild;
trace("Menu Node: " + menuClass.menuNode);
} else {
//DIE
}
};
menuXML.load(xmlURL);
}
public function getBoxNum(name:String):Number {
trace("Menu Node: " + menuNode); // IT'S UNDEFINED HERE!
return searchNodes(menuNode, "item", name);
}
I have access to the menu class in my loadXML procedure so I know that’s not the issue. But as soon as I get out of this method and try
to refer to menuNode (in the getBoxNum() function), I get an undefined. What am I missing?
Thanks for the help,
panhead490