5 Replies Latest reply on Mar 26, 2015 11:31 AM by kglad

    XML.prototype.load

    dazzfazz

      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.

        • 1. Re: XML.prototype.load
          kglad Adobe Community Professional & MVP

          create a function that prepends that string.

          • 2. Re: XML.prototype.load
            dazzfazz Level 1

            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.

            • 3. Re: XML.prototype.load
              kglad Adobe Community Professional & MVP

              you don't need to hijack anything:

               

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

              xml.load('yourprependedstring'+xmlS);

              }

              • 4. Re: XML.prototype.load
                dazzfazz Level 1

                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

                • 5. Re: XML.prototype.load
                  kglad Adobe Community Professional & MVP

                  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.