I’m attemping to add some functions to the XMLNode class (more specifically functions to make the calling of XPath functions easier).
I’ve got an .as file which includes this code:
MLNode.prototype.getXMLAttribute = function(XPath:String, attributeName:String):String {
return com.xfactorstudio.xml.xpath.XPath.selectSingleNode(this,XPath).attributes[attributeName];
}
Now, I’ve got another .fla file from which I’m calling these from with this code:
#include "initialization.as"
var settings_xml:XML = new XML();
settings_xml.ignoreWhite = true;
settings_xml.load("set.xml");
settings_xml.onLoad = function() {
test = this.firstChild;
if (test instanceof XMLNode) trace("YEAAA");
trace(test.getXMLAttribute("logos/biglogo","path"));
}
Now this code will work fine, but if I try to preset the test variable type for ‘test’ I got an error. So if I add a ling of code directly after the settings_xml definition like this:
var test:XMLNode; or var test:XMLNode = new XMLNode();
and then try to compile I get the following error:
Error Scene=Scene 1, layer=Layer 1, frame=1:Line 12: There is no method with the name ‘getXMLAttribute’.
trace(test_xmlNode.getXMLAttribute(“logos/biglogo”,“path”));
Why is it that as soon as I try to hard type the variable, it stops searching the prototype object for functions?