Skip to main content
dazzfazz
Inspiring
March 26, 2015
Answered

XML.prototype.load

  • March 26, 2015
  • 1 reply
  • 627 views

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.

This topic has been closed for replies.
Correct answer kglad

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


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.

1 reply

kglad
Community Expert
Community Expert
March 26, 2015

create a function that prepends that string.

dazzfazz
dazzfazzAuthor
Inspiring
March 26, 2015

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.

kglad
Community Expert
Community Expert
March 26, 2015

you don't need to hijack anything:

yourcustomloadfunctionF(xml:XML,xmlS:String):Void{

xml.load('yourprependedstring'+xmlS);

}