Today a guy in the FLEX group brought up AIR cache clearing, so I went wandering through the official docs again, and while I was at it I came across AIR’s URL schemes. Two of them I’d never used: app: and app-storage:. Here are the details:
The standard URL schemes below are supported in any security sandbox in AIR: http: and https: — these two are of course web URLs. file: — this one is of course a local file URL.
The schemes below are used by content running in the application security sandbox: app: Use this to specify a path relative to the top level of the application installation directory (that is, the application source directory) — the directory that contains the application descriptor file. For example, the one below points to the resources subdirectory under the application’s top-level directory: app:/resources
When running in the ADL application, the application source directory is the directory where the application descriptor file lives. app-storage: specifies a path relative to the application storage directory. AIR defines a unique application storage directory for each user, and that directory is used to hold the application’s settings information. Its location depends on the user name, the AIR application ID, and the publisher ID.
Specifically, on Windows it’s under user name/Application Data/applicationID.publisherID/Local Store/, for example C:DOCUMENTS AND SETTINGSBABBAGEAPPLICATION DATACOM.EXAMPLE.TESTAPP.02D88EEED35F84C264A183921344EEA353A629FD.1LOCAL STORE
On Mac OS it’s under /Users/user name/Library/Preferences/applicationID.publisherID/Local Store/, for example /USERS/BABBAGE/LIBRARY/PREFERENCES/COM.EXAMPLE.TESTAPP.02D88EEED35F84C264A183921344EEA353A629FD.1/LOCAL STORE
The URL of a File object created with File.applicationStorageDirectory (and its url property) is the app-storage URL scheme, like this: var dir:File = File.applicationStorageDirectory; dir = dir.resolvePath("preferences"); trace(dir.url); // 输出:app-storage:/preferences
Just like FileStream or Sound objects, you can use these URL schemes to define URLRequest objects that point to any number of different object URL requests. You can also use these URL schemes in HTML content running in AIR; for example, you can use them for the src attribute of an IMG tag. However, in content in the application security sandbox, you can only use the AIR-specific URL schemes (app: and app-storage:).
References: http://livedocs.adobe.com/air/1/devappsflash/security_1.html#1043607(AIR安全). (Mistakes are inevitable — please point them out.)