Air file.nativePath Vs. file.url

Is it me or is file.url a lot easier to use than file.nativePath in Adobe AIR. Maybe I’m missing something because every tutorial or code snippet I can find uses file.nativePath.

I’m busy building an AIR application that can be used on Windows and Mac OS. I have to take care of the file structure of both systems. After I test my application on a Mac I couldn’t load anything from it. The reason of this problem is that Mac needs “file://” in front of the file URL to load the file correct.

When I had this problem I searched the internet for a solution. I found very complex solutions at EverythingFlex and Snipplr. But then I start to examine the File object and found just the right file url (on the Mac it adds “file://” in front of the url) just accessible with File.url. Then I tested it on Windows and it worked perfect.

I see no reason why I shouldn’t use this simple version of all the long code solutions that are available on the web. But like I said maybe I’m missing something?

Comments

7 responses to “Air file.nativePath Vs. file.url”

  1. Quentin Avatar

    I was wondering the exact same thing…
    If someone has a clue!

  2. Greg Avatar

    The nativePath is formatted to a path the average user understands. Some users might see file:///C:/Program Files/… on windows and say: huh?

    nativePath would read so they see C:Program Files… which would make sense to them.

    I’ve always used nativePath when displaying a filepath to a user (like depicting a file they’ve chosen), and a url when you are loading that content into an Image component or something.

  3. Arno Manders Avatar

    that sounds like a reasonable purpose to use nativePath. But why are the people of those scripts using file.nativePath instead of file.url?

  4. ovaseethell Avatar
    ovaseethell

    Howdy – This is a great place

    Just registered and wanted to say hello.

  5. deRijk Avatar
    deRijk

    This saved my day Arno.

  6. Chris Dennett Avatar
    Chris Dennett

    Thank you for this. Swapping .nativePath for .url has now made me all Mac compatible which gives me a nice warm feeling inside… or that may be the wine. But either way, thank you for your post, you’re a wonderful person.

  7. starlover Avatar
    starlover

    And?? Did you miss something?

    I too ran into the problem that my images did not load on a mac when i use nativepath as saved image urls.

    Can i safely use url instead?

Leave a Reply to deRijk Cancel reply

Your email address will not be published. Required fields are marked *