转自:http://www.jeffryhouser.com/index.cfm/2008/2/19/Local-Access-URLs-in-Adobe-AIR
Local Access URLs in Adobe AIR
Posted At : February 19, 2008 9:00 AM | Posted By : Jeffry Houser
Related Categories: Flex,Professional,AIR
One of the benefits of Adobe AIR, over a browser based application, is that you can have access to the local file system. This question came up on the House of Fusion Flex Coders list; and I thought I'd blog the answer.
I truncated the original question a bit.
I've got an Flex/AIR app which contains a SQLite db and some photos which will be included in the install package.
[cut]
I need to open the db file locally [without using a hard coded absolute path]
How might I go about referencing it this file so that it will work both in development, and installed?
Adobe AIR offers two URL schemes for accessing the local file system. Documentation is here.
* 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.
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 ;
Since these are static properties you do not need to create an instance of the file class to access them. I'm not sure if one method is preferred over the other, as both seem easily transportable between systems and applications.
On Wednesday the 20th, I'll be all over. I'll be speaking to a business group at the Meriden Connecticut Chamber of Commerce in the morning. I'm speaking as part of their Small Business Institute; and will be speaking on the differences between web sites, web applications, and Internet applications.
In the evening, I'm off to the Boston User Group to speak on code reuse between Flex and AIR. This will be my last time giving the presentation before heading off to 360Flex in Atlanta. Are you in Atlanta and want to get together sometime on Saturday -Wednesday let me know.
[转]Local Access URLs in Adobe AIR
相关推荐
- 员工考勤打卡时,如何避免非本人代替打卡? - 华为云开发者联盟 - 博客园
- Web Components从技术解析到生态应用个人心得指北 - zhoulujun - 博客园
- 【经典问题】mysql和redis数据一致性问题 - Scotyzh - 博客园
- vs出现错误,无法启动 Visual Studio。StreamJsonRpc.ConnectionLostException:在请求完成之前,与远程的JSON-RPC连接已丢失_客服专区-CSDN问答
- 【转】Chrome内核浏览器打开网页报 错误代码: ERR_TIMED_OUT - m_lm的个人空间 - OSCHINA - 中文开源技术交流社区
- ASP.NET Core WebApi配置跨域_asp.net core webapi 跨域-CSDN博客
- C# 怎么用OpenCVSharp4实现图片表格识别
- ChatGPT 本地部署及搭建_孟郎郎的博客-CSDN博客