2 Replies Latest reply on Dec 5, 2008 12:29 PM by Joe ... Ward

    Using  file:// in HTML control

      I am trying to load a local file to the HTML component but it doesn't seem to load. I have verified the path. The code is below. Am I missing something?


      <?xml version="1.0" encoding="utf-8"?>
      <mx:WindowedApplication xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="OnInit()">
      <mx:HTML width="780" height="400" id="html" />
      public function OnInit():void
      html.location ="file://"+File.applicationDirectory.nativePath+"/cnn.html";
        • 1. Re: Using  file:// in HTML control
          Scott McAllister
          Hi Ralph,

          I've had similar hangups in my development. I saw the following line in the livedocs section on the File class that may be of help: "The url property for this object uses the app URL scheme (not the file URL scheme). This means that the url string is specified starting with "app:" (not "file:" )."

          With that said I would have your location value look something like: "app:/cnn.html" (as it looks like the cnn.html file is at the root of your application).

          One resource that really helped me wrap my mind around the whole local file access is Jeffry Houser's blog post on the subject.


          • 2. Re: Using  file:// in HTML control
            Joe ... Ward Level 4

            tracing your html location shows something that isn't a well formed URL.

            You may want to do something like this instead:
            var pageToLoad:File = File.applicationDirectory.resolvePath("cnn.html");
            html.location = pageToLoad.url;

            Native paths may work as URLs in some cases, but not all -- and can give you trouble when your app is run on a different OS then you develop/test on.