1 Reply Latest reply on Feb 18, 2010 1:25 AM by Vikram_S

    HTML Loader Help

    Eugelai84

      I can't seem to get my Flex program to work. I'm trying to load a pdf file using HTML loader. I'm using Flash Builder and I get errors. The errors I get are:

       

      Access of Undefined Property htmlLoad

      Access of Undefined Property urlReq

      Call to a possibly undefined method addChild.

       

      Can someone please tell me what i'm doing wrong?

       

       

      <s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
                                  xmlns:s="library://ns.adobe.com/flex/spark" 
                                  xmlns:mx="library://ns.adobe.com/flex/halo">
      <fx:Script>
           <![CDATA[
                import flash.display.*;
                import flash.net.URLRequest;
                if(HTMLLoader.pdfCapability == HTMLPDFCapability.STATUS_OK) 
                {
                     var htmlLoad:HTMLLoader = new HTMLLoader();
                     var urlReq:URLRequest = new URLRequest("http://www.evilfishsolutions.com/test.pdf");
                          
                
                     
                     
                     htmlLoad.width = 800;
                     htmlLoad.Height = 800;
                     htmlLoad.load(urlReq); 
                     addChild(htmlLoad);
                     
                     
                }
                else 
                {
                     trace("PDF cannot be displayed. Error code:", HTMLLoader.pdfCapability);
                }
      
           ]]>
      </fx:Script>
      </s:WindowedApplication>
      
        • 1. Re: HTML Loader Help
          Vikram_S Level 2

          Hi,

          I think you should include your code in function.

           

          try this.

                      import flash.display.*;
                      import flash.net.URLRequest;
                      public function addHTML():void{
                          if(HTMLLoader.pdfCapability == HTMLPDFCapability.STATUS_OK)
                          {
                              var htmlLoad:HTMLLoader = new HTMLLoader();
                              var urlReq:URLRequest = new URLRequest("http://www.evilfishsolutions.com/test.pdf");
                                  htmlLoad.width = 800;
                                  htmlLoad.height = 800;
                                  htmlLoad.load(urlReq);
                                  addChild(htmlLoad);
                          }
                          else
                          {
                              trace("PDF cannot be displayed. Error code:", HTMLLoader.pdfCapability);
                          }
                      }

           

          Thanks,

          Vikram