Copy link to clipboard
Copied
Hi,
I need to extend the XML load method as so I can add a prefix onto the XML.load("my_xml_data_file_location.xml") as so the actual url request was XML.load("http://www.myServerLocation.com/my_xml_data_file_location.xml")
So my first thought was to hijack the XML.prototype.load method but for the life of me I cannot find a reference to the XML.prototype.load function. And then I would add code to the XML.prototype.load method to query the URL string to see if it has or has not a http server URL location .
Thanks in advance.
use:
var XMLLoad:Function=XML.prototype.load;
XML.prototype.load=loadF;
function loadF(s:String):Void{
XML.prototype.load=XMLLoad;
this.load('yourprependedstring'+s);
XML.prototype.load=loadF;
}
p.s when using the adobe forums, please mark helpful/correct responses, if there are any.
Copy link to clipboard
Copied
create a function that prepends that string.
Copy link to clipboard
Copied
Already thought of that one but that would need a lot of effort to trawl through inherited code and I don't have the time to do this.
So the easiest approach I thought was to hijack the XML.prototype.load method and add the additional "checking code" into this method.
Copy link to clipboard
Copied
you don't need to hijack anything:
yourcustomloadfunctionF(xml:XML,xmlS:String):Void{
xml.load('yourprependedstring'+xmlS);
}
Copy link to clipboard
Copied
Hi,
Thanks for coming back so quickly.
I failed to add that the inherited code uses the XML.load methods in many, many locations. Hence wanting to use an extended XML.prototype.load method. That way I only need to apply this code in one place and at run time, everywhere the XML.load is used, the prototype will do all the pre-checking. Also, it will not need to add any code anywhere else.
Thanks
Copy link to clipboard
Copied
use:
var XMLLoad:Function=XML.prototype.load;
XML.prototype.load=loadF;
function loadF(s:String):Void{
XML.prototype.load=XMLLoad;
this.load('yourprependedstring'+s);
XML.prototype.load=loadF;
}
p.s when using the adobe forums, please mark helpful/correct responses, if there are any.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now