5 Replies Latest reply on Dec 22, 2006 3:20 AM by Hugo_Core

    navigateToURL

    jnic79
      Hi, I have a problem to display a file in a netscape window with the method navigateToURL. It brings, in parameter, the url of the file (it's path directory). It would be simple if this file was in my flex project directory (indeed, url would be, for example, url ="./pathDirectory/fileName.pdf").

      But here, that file is not in my flex project but in the temporary directory (for the loaded files from a web application)

      Does anybody have an idea on how the url path should be to access this file and display it in a netscape window ??

      Thanks in advance

      jnic
        • 1. navigateToURL
          Hugo_Core
          Hi jnic79,

          First time posting, but i hope i can help :D
          So..

          I Usually call a Function to use a navigateToURL() with a URLRequest.
          Here's a simple sample.

          <mx:Script>
          <![CDATA[
          import flash.net.*;
          public function openMyPDF():void {
          var u:URLRequest = new URLRequest(" http://www.adobe.com/products/flex/whitepapers/pdfs/flex2wp_technicaloverview.pdf");
          navigateToURL(u,"_blank");
          }
          ]]>
          </mx:Script>


          <mx:LinkButton label="Flex WhitePaper" click="openMyPDF()"/>


          Waiting for your FeedBack.
          • 2. Re: navigateToURL
            jnic79 Level 1
            Thank you for your answer !

            What you describe is correct, but not really the problem that I have...

            I give maybe more explanations :

            Some files, that I want to display, are in the directory T: \ myPath \ temporaryFiles

            And my Flex Project is in C: \ myPathProject \ flexProject

            If the file fileToDisplay.pdf I want to display was in a subfolder in flexProject, the url would be url = ". / pathToFile / fileToDisplay"

            But here, if a put the the point before the first slash, with the path to the file to display, I receive an error, because I refeer to the flexProject, and it does not contain a such file. Indeed, that file is in T : \myPath \ temporaryFiles.

            My problem is : How to refeer to this file in T : \myPath \ temporaryFiles from a mxml file in the flexProject

            url = "T : \ \myPath \ temporaryFiles" ? I have tried that, it does not work. I always say that it does not exist.... :-(

            If you have an idea for solving that problem.... that would be great :-)
            • 3. Re: navigateToURL
              Hugo_Core Level 1
              i think i got it..

              I done a quick test with the information you give.

              - I created a folder in my disk root : c:\test


              - I created a txt file : test.txt


              In my Application i put it :

              <mx:Script>
              <![CDATA[
              import flash.net.*;
              public function openMyPDF():void {
              var u:URLRequest = new URLRequest("c:/test/test.txt");
              navigateToURL(u,"_blank");
              }
              ]]>
              </mx:Script>


              <mx:LinkButton label="Flex WhitePaper" click="openMyPDF()"/>

              Conclusion:

              MX Application -> C:\FlexWorkspace\cre_marcacao\bin\pdf.html

              File to Open -> C:\test\test.txt

              Ps: Make notice that when you Run your application is deploy'it to the Bin folder, so you have to make a path that returns all way back, anless you use a complet path like in sample above. You don't wanna use a complet ? Try This Way:

              <mx:Script>
              <![CDATA[
              import flash.net.*;
              public function openMyPDF():void {
              var u:URLRequest = new URLRequest("../../../test/test.txt");
              navigateToURL(u,"_blank");
              }
              ]]>
              </mx:Script>


              <mx:LinkButton label="Flex WhitePaper" click="openMyPDF()"/>

              Hope I Help ^^
              [[]] Core

              • 4. Re: navigateToURL
                jnic79 Level 1
                Thanks for help, but I do not know why it doesn't work...... It seems to be the wright way to do that. Maybe I have another problem on my application. I will let you know as soon as the application will work.

                jnic
                • 5. Re: navigateToURL
                  Hugo_Core Level 1
                  Well if you wanna post the complete code soo i can help you better.

                  Im my system work well as i said. Keep trying don't give up!

                  Core