4 Replies Latest reply on Feb 18, 2012 8:42 AM by DonMitchinson

    Load a local file

    JW1015

      I have searched every site and blog to try to find a method that actually works without success.

       

      I want to load a pdf from the application directory on an android, the method works fine debugging on a desktop

      but locks up on an actual device.

       

      I have a Motorola Xoom with Honeycombe 3.

       

      In my project I use a local sql database and can access that fine on the Xoom.

       

      public function listGroups(brand:String):Array

              {

                  var sqlConnection:SQLConnection;

                  sqlConnection = new SQLConnection();

                  sqlConnection.open(File.applicationDirectory.resolvePath("manuals.db" ));

                  var stmt:SQLStatement = new SQLStatement();

                  stmt.sqlConnection = sqlConnection;

                  stmt.text =

                      "SELECT * FROM keywords  " +

                      "WHERE brand = '" + brand + "' " ;

                 

                  stmt.execute();

                  var result:Array = stmt.getResult().data;

                  return result;         

              }

       

      But I cannot get a working path for the pdf to open in a StagewebView using either one of the path var I have.

       

      <fx:Script>

             

              <![CDATA[

                 

                  import mx.events.FlexEvent;

                 

                  private var stageWebView:StageWebView;

                  // will load a pdf or swf file from local storage

                  public var path:String = new File(new File("app:/Alpha.pdf").nativePath).url;

                  public var manualFile:String = new File(File.applicationDirectory.resolvePath("Alpha.pdf").nativePath).url;

                 

                 

                 

                 

               protected function applicationCompleteHandler(event:FlexEvent): void

                     

                  {

                     

                      if(StageWebView.isSupported== true){

                         

                          stageWebView = new StageWebView();

                     

       

                         

                          stageWebView.viewPort = new Rectangle(5,100,stage.width-10,stage.height-90);

                         

                          stageWebView.stage = this.stage;

                         

                          stageWebView.addEventListener(LocationChangeEvent.LOCATION_CHANGE,                                                

                             

                              locationChangedHandler);

                         

                          

                         

                          stageWebView.loadURL(manualFile);

                         

                      } else {

                         

                          urlAddress.text = "StageWebView not supported" ;

                         

                      }

                     

                  }

                 

      I am beginning to think it impossible, has anyone achieved to do this, maybe another android device.

       

      Any thoughts would be great, a solution even better.