3 Replies Latest reply on Jan 3, 2009 5:48 AM by Newsgroup_User

    Relative file URLs with URLLoader?

    dah328
      Is it possible to use relative paths in file:// URLs loaded by the URLLoader class? I have been unable to load any file URLs without specifying the full path of the file (e.g., file://c:/data/local/etc...) in the URL which is decidedly less useful than being able to specify a relative path.
        • 1. Re: Relative file URLs with URLLoader?
          Level 7

          "dah328" <webforumsuser@macromedia.com> wrote in message
          news:gjlle7$fs6$1@forums.macromedia.com...
          > Is it possible to use relative paths in file:// URLs loaded by the
          > URLLoader
          > class? I have been unable to load any file URLs without specifying the
          > full
          > path of the file (e.g., file://c:/data/local/etc...) in the URL which is
          > decidedly less useful than being able to specify a relative path.
          >

          Try something like:
          url = "data/settings.xml";

          var settingsLoader:URLLoader = new URLLoader()

          var settingsRequest:URLRequest = new URLRequest(url);


          settingsLoader.dataFormat = URLLoaderDataFormat.TEXT;

          settingsLoader.addEventListener(Event.COMPLETE, settingsLoadHander);

          settingsLoader.load(settingsRequest);


          • 2. Relative file URLs with URLLoader?
            dah328 Level 1
            So if I use, for example, "data/settings.xml" as the URL, what directory is that relative to for a locally-run Flex app? I tried that in a sample application and it is not relative to the directory in which the SWF file is located and I couldn't figure out what else it would be relative to.

            • 3. Re: Relative file URLs with URLLoader?
              Level 7

              "dah328" <webforumsuser@macromedia.com> wrote in message
              news:gjmsj9$57d$1@forums.macromedia.com...
              > So if I use, for example, "data/settings.xml" as the URL, what directory
              > directory is that relative to for a locally-run Flex app? I tried that
              > and it
              > is not the directory in which the SWF file is located.
              >

              If your main mxml file is in your "src" directory, then you'd have a "data"
              directory inside that, and inside that, you'd put "settings.xml".

              HTH;

              Amy