2 Replies Latest reply on Sep 3, 2009 10:12 AM by Rothrock

    Migrate existing code of AS3 to AS2 - URLRequest, URLLoader

    mgmcs06

      Hi,

      I have written code to read an XML file by using URLRequest and URLLoader in ActionScript 3.0. Code is pasted below. This runs well in AS3.  Problem I am facing is because I wrote this in AS3, I am not able to use the DateChooser component in another part of the flash module because it seems like DateChooser component is not supported in AS3. So I want to migrate my below AS3 code back to AS2.

       

      **** Code in AS3 (I need help in writing equivalent code in AS2) :-

       

      var xmlText:XML ;
      var xmlReq:URLRequest = new URLRequest("myFile.xml");
      var xmlLoader:URLLoader = new URLLoader();

       

      xmlLoader.load(xmlReq);
      xmlLoader.addEventListener(Event.COMPLETE,xmlLoaded);


      function xmlLoaded(event:Event):void
      {
          xmlText = new XML(xmlLoader.data);   
          info_txt.htmlText = xmlText.someTag ;
      }

       

      **** I cannot use the above as is because, when I change the publish settings from AS3 to AS2, I get following errors -

      The class or interface 'URLRequest' could not be loaded.

      The class or interface 'URLLoader' could not be loaded.

      The class or interface 'Event' could not be loaded.

       

      Same works well in AS3. What should I do to make this work in AS2 or can anyone direct me in writing an equivalent in AS2.

      Please assist.

      Thanks in advance.

      MG