I'm having trouble calling XPath from one of my as2.0 classes. I'm fairly new to as2.0, so I'm sure it's just a problem with my syntax as I'm still getting a handle on scope and such. When I try to use the method XPath, I get the error "There is no method with the name 'XPath'." I guess that means that I can't reference the XPath method from within a method of a class I created, right? What am I doing wrong?
Here's a simplified example of what I'm trying to accomplish.
Class code (actionscript)
PHP Code:
class AudioData {
var myXML:XML
var xmlfile:String
function AudioData(x:String){ // CONSTRUCTOR
myXML = new XML();
xmlfile = x;
loadXMLData(xmlfile) // CALL THE METHOD THAT LOADS THE XML DATA
}
private function loadXMLData():Void{
myXML.load(xmlfile); // LOAD THE XML FILE
myXML.onLoad = function(success){
if (success){
// HERE'S THE PROBLEMATIC LINE OF CODE!
var recordset = XPath.selectNodes(this,"/Path/To/XML/Node");
for (n=0; n<recordset.length; n++){
trace (recordset[n]) // PRINT TO THE OUTPUT WINDOW
}
}
}
}
}
on frame 1 of my main timeline
code:
// Import the XPath classes
import com.xfactorstudio.xml.xpath.*;
allData = new AudioData("xmldata.xml");
-Paul