3 Replies Latest reply on Mar 30, 2010 8:19 AM by sway13

    navigateToURL() not working when trying to open a file.




      I am working on an AIR Flex application running on the local Windows system.

      Following code works when accessing the file from my local system.

      I want to display a file which is present in a remote server.


      In ActionScript, The below code does NOT work.


      var url:String = "\\<RemoteServerName>\d1\abc.pdf";





        request:URLRequest = new URLRequest(url);







      When I am trying to open the file manually, e.g. Start -> Run -> Open (\\<RemoteServerName>\d1\abc.pdf), the document opens fine.


      Please let me know if there are any other way of opening a file from remote location.


      Thank You,


        • 1. Re: navigateToURL() not working when trying to open a file.
          Romil Mittal Adobe Employee

          URLRequest class checks for the protocol of the URL string and depending on that it creates the object. If it doesn't find any protocol, it prepends "app:" as the default protocol assuming that the path is referring to a file in the application. But when you call navigateToURL with that URLRequest, the default browser does not understand app: URL and fails to open it.


          Cutting long story short, you need to specify the protocol name in your URL string.



          • 2. Re: navigateToURL() not working when trying to open a file.
            rkewlani Level 2

            You can map your network drives to one of the drive letters & later access it using file:// protocol.


            From DOS command prompt run:

            net use z: \\<RemoteServerName>\d1


            And then chage the url request to:

            request:URLRequest = new URLRequest(file:///z:/abc.pdf";);




            It would be better if you could just run an http server on your remote machine & access it directly using http:// protocol.

            request:URLRequest = new URLRequest(http://<RemoteServerName>/d1/abc.pdf";);

            • 3. Re: navigateToURL() not working when trying to open a file.
              sway13 Level 1

              Thanks rkewlani,


              I think I am geting closer for a solution though I am getting a new error after changing the URL.


              My new url:String looks like


              var url:String = file:\\RemoteServerName\d1\abc.pdf;

              var  request:URLRequest = new URLRequest(url);


              Error I get is :

              ------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------ ------------------------

              SecurityError: Error #2121: Security sandbox violation: navigateToURL: app:/XXX.swf cannot access file:\\RemoteServerName\d1\abc.pdf;. This may be worked around by calling Security.allowDomain.

              ------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------ ------------

              I added Security.allowDomain("*") to the creationComplete event of the form, Now the error is


              SecurityError: Error #3207: Application-sandbox content cannot access this feature.

              at flash.system::Security$/allowDomain()


              Any help on this.