Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

XML.prototype.load

Explorer ,
Mar 26, 2015 Mar 26, 2015

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.

TOPICS
ActionScript
556
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Mar 26, 2015 Mar 26, 2015

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.

Translate
Community Expert ,
Mar 26, 2015 Mar 26, 2015

create a function that prepends that string.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 26, 2015 Mar 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 26, 2015 Mar 26, 2015

you don't need to hijack anything:

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

xml.load('yourprependedstring'+xmlS);

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 26, 2015 Mar 26, 2015

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 26, 2015 Mar 26, 2015
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines