4 Replies Latest reply on Dec 5, 2007 12:32 AM by FlexPrashant

    error 1009 in httpservices

    FlexPrashant Level 1
      Hello

      I have written a code to call 2 different xml with a single HTTPService
      object but i am getting a error and when i again click the button it working
      mean to say i called this function on button click
      when i click on button i got error

      TypeError: Error #1009: Cannot access a property or method of a null object reference.
      at Anatomy/getxml()
      at Anatomy/__btn2_click()

      but again i click on button i got the result

      and when i click on second button the last result not change and again i click then new result come
      plz help me

      the code is

      <HTTPService id="path1" url="path1.xml" useProxy="false" >

      </HTTPService>

      <Script>
      <![CDATA[

      import mx.controls.Button;
      import mx.controls.Image;
      import mx.collections.ArrayCollection;
      import mx.core.UIComponent;
      import mx.controls.Alert;

      /* private function next():void
      {
      getxml();
      if(book2.currentPageIndex+2 < book2.pageCount)
      book2.turnToPage(book2.currentPageIndex + 2);

      }
      private function previous():void
      {
      if(book2.currentPageIndex > 1)
      book2.turnToPage(book2.currentPageIndex - 2);
      }*/

      // This function is using to call the images from xmls(path1 & path2 )

      private function getxml(btn:Button):void
      {

      var btnid:String = btn.id;
      var content:Array = book.content;
      var i:Number =0;
      content.length=0;

      if(btnid=="btn2")
      {
      //path1.url=null;
      path1.url ="path2.xml";
      path1.send();
      }

      if(btnid=="btn1")
      {

      // path1.url="";
      path1.url="path1.xml";
      path1.send();
      }

      var len:ArrayCollection= path1.lastResult.images.image;
      for(i=0;i<len.length;i++)
      {

      var newPage:Imag= new Imag();
      newPage.source = path1.lastResult.images.image .source;
      content.push(newPage);
      }
      book.content = content;
      }


      /* public function seturl(urlstring:String):void
      {

      path1.url = urlstring;
      }*/

      ]]>
      </Script>