Subscribe

  • Subscribe  

Adobe AIR URL Schemes for Local Access

Posted by Charles | February 20, 2008 .

How do you access local resource without using a hard coded absolute path? Jeffre houser has a quick tip for an answer.

There are two URL schemes come from Adobe AIR:

  • app:/: App URLs are relative to the application install directory. This is what the poster would need to access the assets he was distributing with his application.
  • app-storage:/: The app-storage URL will get you to the application’s storage directory. On a Windows (XP) machine this is under “Documents and Settings/username/applicationdata/”

As an indirect correlation, if you need the absolute paths to the application install directory or the application root directory, you can get them using the File Class. So, as Jeffre indicates:

Somewhere in your ActionScript code, just import the class:

import flash.filesystem.File;

Two static variables exist on the File class, applicationDirectory and applicationStorageDirectory. This code saves them to local variables:

public var appDirectory : String = File.applicationDirectory ;
public var storageDirectory : String = File.applicationStorageDirectory ;

That’ll do the trick.

Leave a Comment

If you would like to make a comment, please fill out the form below.


Name

Email

Website

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

Comments

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word


Related Posts

4 Comments so far
  1. Darrell  April 24, 2008 7:48 am

    Nice post Charles … a little nugget more of insight into the bizarre complexities of AIR file storage.

    I was hoping to have an AIR application be a data manager (i.e. read from a source XML file, provide application functionality to manipulate the data and then write back out to the sameXML file). Searching so far has made me come to the conclusion I can only write back out to the File.applicationStorageDirectory, which as you conclude above goes into the deep dark depths of a My Documents hidden folder.

    Then I was hoping to have another Flex SWF application read the newly updated XML file for data input content … problem is I can’t see so far how I can get the SWF to read that file. Even if I point it to the exotically named hidden My Documents folder URL, it fails to find/read it (same logged on user running both apps) … is this an XP security blocking thing, or is the HTTPService objecting to the windows style full drive path/directory naming convention…

  2. Darrell  April 24, 2008 7:51 am

    … data validation cut off my last part to that submission. It continued to say:

    *mx:HTTPService
    url=”C:\Documents and Settings\Darrell\Application Data\applicationAIR.BD7F6092E158CC038D91CDCA067AA8619658B0C9.1\data.xml”*

    I tried turning the \ round to / but neither work … unless I put the SWF on the C:\ drive and do some complex url=”..\..\..\..\……”, but seems messy.

    Anybody out there got a more elegant solution or a fix for above?

    Thanks.

  3. Abdul Jaleel  November 4, 2008 9:37 pm

    it seems nice. But i have a doubt that how can we access the resources like printer ?

  4. Casey Deshotels  February 14, 2009 9:54 pm

    Do you know what the actual path to the application file directory is on a windows machine? I have located the app-storage directory, but not the app. During development and after install?

<

Error. Page cannot be displayed. Please contact your service provider for more details. (24)


Direct TV Offers - usdirect has the best directtv deals