|
|
Home /
Groups /
Adobe Flex
Relative file paths for AIR app dev
I've got an Flex/AIR app which contains a SQLite db and some photos which will be included in the install package.Andy Matthews 02/15/08 09:34 A Could you use app:/ ?Stefan Richter 02/15/08 09:42 A Stefan...Andy Matthews 02/15/08 09:56 A I think he meant his question a bit rhetorically, as hisJeffry Houser 02/15/08 10:28 A Looking now. While I look, how would you define app:/? I mean, of what classAndy Matthews 02/15/08 10:46 A You don't define it anywhere. You just use it in a string. TheJeffry Houser 02/15/08 11:28 A I think it does. I'll give it a shot. Thanks for your time Jeffry, all.Andy Matthews 02/15/08 11:36 A Okay ...Andy Matthews 02/15/08 12:05 P Andy Matthews wrote:Jeffry Houser 02/15/08 12:26 P Okay...Andy Matthews 02/15/08 01:56 P Andy Matthews wrote:Jeffry Houser 02/15/08 03:07 P Okay...Andy Matthews 02/15/08 04:30 P Andy Matthews wrote:Jeffry Houser 02/15/08 05:21 P Jeffry...Andy Matthews 02/16/08 12:17 A I've got an Flex/AIR app which contains a SQLite db and some photos which will be included in the install package. /src faces.db /assets andymatthews.png ericcobb.png I need to open the db file locally rather than what I'm currently using which is: var db:SQLConnection = new SQLConnection(); var file:File = new File("//Ds-fs1/Shared/Faces/faces.db"); db.open(file); Obviously that file path won't exist on the end user's machine. How might I go about referencing it this file so that it will work both in development, and installed? Could you use app:/ ? Fromt he docs: app:/ An alias to the application directory. Files accessed from this path will be assigned the application sandbox and have the full privileges granted by the runtime. Regards, Stefan On 15 Feb 2008, at 14:00, Andy Matthews wrote: ----- Excess quoted text cut - see Original Post for more ----- Stefan... I don't know if I can, I'm brand new at Flex and AIR. Currently I'm developing off a network drive so that my coworkers and I can share code. If I use the app:/ directory would that pull the working db as well as when the app is installed? andy Could you use app:/ ? Fromt he docs: app:/ An alias to the application directory. Files accessed from this path will be assigned the application sandbox and have the full privileges granted by the runtime. Regards, Stefan On 15 Feb 2008, at 14:00, Andy Matthews wrote: ----- Excess quoted text cut - see Original Post for more ----- I think he meant his question a bit rhetorically, as his recommendation is correct. "app:/" will give you a direct line into the application root. "app-storage:/" will get you to user's local storage directory, which (at least on Windows) is not the same as the application install directory. Search the AIR documentation for "Supported URL schemes" for more info. As an indirect correlation, you can get the absolute paths to application root or storage root using two properties on the File class: applicationDirectory and applicationStorageDirectory. Andy Matthews wrote: ----- Excess quoted text cut - see Original Post for more ----- Looking now. While I look, how would you define app:/? I mean, of what class it associated? This? public var localPath:FileReference = app:/; This? public var localPath:String = 'app:/'; andy I think he meant his question a bit rhetorically, as his recommendation is correct. "app:/" will give you a direct line into the application root. "app-storage:/" will get you to user's local storage directory, which (at least on Windows) is not the same as the application install directory. Search the AIR documentation for "Supported URL schemes" for more info. As an indirect correlation, you can get the absolute paths to application root or storage root using two properties on the File class: applicationDirectory and applicationStorageDirectory. Andy Matthews wrote: > Stefan... > > I don't know if I can, I'm brand new at Flex and AIR. Currently I'm > developing off a network drive so that my coworkers and I can share code. If > I use the app:/ directory would that pull the working db as well as when the ----- Excess quoted text cut - see Original Post for more ----- be > assigned the application sandbox and have the full privileges granted by the ----- Excess quoted text cut - see Original Post for more ----- You don't define it anywhere. You just use it in a string. The original code on this thread, would be re-written like this: var db:SQLConnection = new SQLConnection(); var file:File = new File("app:/Ds-fs1/Shared/Faces/faces.db"); db.open(file); AIR sees it when accessing a file and just knows where to look. Kind of like the web browser knows the difference between "http://", "ftp://:, and "file://". Air knows the difference between "C:\", "app:/", and "app-storage:/". Does that answer the question? Andy Matthews wrote: ----- Excess quoted text cut - see Original Post for more ----- I think it does. I'll give it a shot. Thanks for your time Jeffry, all. You don't define it anywhere. You just use it in a string. The original code on this thread, would be re-written like this: var db:SQLConnection = new SQLConnection(); var file:File = new File("app:/Ds-fs1/Shared/Faces/faces.db"); db.open(file); AIR sees it when accessing a file and just knows where to look. Kind of like the web browser knows the difference between "http://", "ftp://:, and "file://". Air knows the difference between "C:\", "app:/", and "app-storage:/". Does that answer the question? Andy Matthews wrote: ----- Excess quoted text cut - see Original Post for more ----- directory. ----- Excess quoted text cut - see Original Post for more ----- Okay ... That doesn't appear to be working, but I think it's my fault for not explaining myself correctly. All of my dev files are located here (network drive): V:\wwwroot\FlexProjects\Faces\src Faces.db Faces.mxml etc. But the app will probably get installed here: C:\Program Files\Faces Is there some way for Flex to know that while I'm developing, when I say Faces.db I mean V:\wwwroot\FlexProjects\Faces\src\Faces.db but when the app is installed and running on a user's machine I mean: C:\Program Files\Faces\Faces.db Lastly, is that even where the db would get installed on the user's machine, or would it get installed somewhere else? Thanks for being patient with me. I know what I want to do, I just don't know how to get it done. andy You don't define it anywhere. You just use it in a string. The original code on this thread, would be re-written like this: var db:SQLConnection = new SQLConnection(); var file:File = new File("app:/Ds-fs1/Shared/Faces/faces.db"); db.open(file); AIR sees it when accessing a file and just knows where to look. Kind of like the web browser knows the difference between "http://", "ftp://:, and "file://". Air knows the difference between "C:\", "app:/", and "app-storage:/". Does that answer the question? Andy Matthews wrote: ----- Excess quoted text cut - see Original Post for more ----- I strongly recommend creating a development environment similar to what your production environment is going to be like. It'll make your life easier in the long run. That said, you could store the database location in some form of config file, perhaps an XML file. Then use different Config file for "production vs development". Of course, you'll have to remember to change your config file when exporting a release version. Doable, but tedious. I believe you can also set a version number in the app-config, and then do a compare "if Dev go here for file, else go here". Of course, once again, before exporting the release version you'd have to change the file. Doable, but tedious. > Lastly, is that even where the db would get installed on the user's machine, > or would it get installed somewhere else? If it is a part of your AIR installer, it will get installed into the application's install directory. I think you can make directory suggestions (via the -app.xml config file), but the user can really set that path to anything when they install it. -- Jeffry Houser Flex, ColdFusion, AIR AIM: Reboog711 | Phone: 1-203-379-0773 -- Adobe Community Expert <http://www.adobe.com/communities/experts/members/JeffryHouser.html> My Company: <http://www.dot-com-it.com> My Podcast: <http://www.theflexshow.com> My Blog: <http://www.jeffryhouser.com> Okay... So the things I took from this email: 1) A single codebase in a central location is not the best idea. We don't yet have subversion set up for Flex/AIR projects so this is the only way for us to easily share code and keep it up to date. 2) All paths should be abstracted into an external file for ease of updating. If path's change, changing the XML file is all that is required to update the entire app. 3) All files needed to run the actual application get stored in the actual install folder. By default this is C:\Program Files\<appname>, but the user can select any other location. Regardless of where the app is installed, AIR has a single variable which contains the system path to that folder. Sound about right? Andy Matthews wrote: ----- Excess quoted text cut - see Original Post for more ----- I strongly recommend creating a development environment similar to what your production environment is going to be like. It'll make your life easier in the long run. That said, you could store the database location in some form of config file, perhaps an XML file. Then use different Config file for "production vs development". Of course, you'll have to remember to change your config file when exporting a release version. Doable, but tedious. I believe you can also set a version number in the app-config, and then do a compare "if Dev go here for file, else go here". Of course, once again, before exporting the release version you'd have to change the file. Doable, but tedious. > Lastly, is that even where the db would get installed on the user's > machine, or would it get installed somewhere else? If it is a part of your AIR installer, it will get installed into the application's install directory. I think you can make directory suggestions (via the -app.xml config file), but the user can really set that path to anything when they install it. Andy Matthews wrote: ----- Excess quoted text cut - see Original Post for more ----- I whole-heartedly disagree with this. A single code base in a central location is a fantastic idea. And I strongly recommend that location should be a version control repository of some sort. There are a few vendors that you can outsource Source Control hosting too. They'll have you set up much quicker than doing it yourself. > 2) All paths should be abstracted into an external file for ease of > updating. > If path's change, changing the XML file is all that is required to > update > the entire app. Basic principle of encapsulation, design patterns, etc.. is "separate out what changes." I don't have an inherent problem with separating out the paths. However, how often will the location of your database be changing? Rarely! It sounds like you are separating them out not for encapsulation purposes, but to deal with inconsistent development environments paired against a different development environment. It'll probably work for now, but I wouldn't not approach it as a long term fix. ----- Excess quoted text cut - see Original Post for more ----- In most cases, this is true. However if your AIR app is just one piece of a larger application built with its own separate modules, technology, and install process it may not be that simple. -- Jeffry Houser Flex, ColdFusion, AIR AIM: Reboog711 | Phone: 1-203-379-0773 -- Adobe Community Expert <http://www.adobe.com/communities/experts/members/JeffryHouser.html> My Company: <http://www.dot-com-it.com> My Podcast: <http://www.theflexshow.com> My Blog: <http://www.jeffryhouser.com> Okay... I actually found what seems to be a good way of dealing with this. var dbFileName:String = "Faces.db"; dataFile:File = File.applicationDirectory.resolvePath(dbFileName); Returns the correct directory when the app is being run inside FB3, AND when the app gets installed. This is precisely what I was looking for. I just had to hack and hack to find it. Is there any reason not to use this method? To address your response, we actually host our own subversion repository, we just don't have one set up for Flex projects yet. We're a little ahead of our admin. Good points about the db location. I agree fully and will adjust code to address that. This AIR app is a stand-alone dealio, just an emplyee directory. Thanks for all of your time Jeffry, I really appreciate it. I hope I didn't come across as rude, I'm just frustrated at the learning curve. I feel confident that with the stuff I'm learning on this project I'll be in good shape for the rest of my Flex career. andy Andy Matthews wrote: ----- Excess quoted text cut - see Original Post for more ----- I whole-heartedly disagree with this. A single code base in a central location is a fantastic idea. And I strongly recommend that location should be a version control repository of some sort. There are a few vendors that you can outsource Source Control hosting too. They'll have you set up much quicker than doing it yourself. > 2) All paths should be abstracted into an external file for ease of > updating. > If path's change, changing the XML file is all that is required to > update > the entire app. Basic principle of encapsulation, design patterns, etc.. is "separate out what changes." I don't have an inherent problem with separating out the paths. However, how often will the location of your database be changing? Rarely! It sounds like you are separating them out not for encapsulation purposes, but to deal with inconsistent development environments paired against a different development environment. It'll probably work for now, but I wouldn't not approach it as a long term fix. ----- Excess quoted text cut - see Original Post for more ----- In most cases, this is true. However if your AIR app is just one piece of a larger application built with its own separate modules, technology, and install process it may not be that simple. -- Jeffry Houser Flex, ColdFusion, AIR AIM: Reboog711 | Phone: 1-203-379-0773 -- Adobe Community Expert <http://www.adobe.com/communities/experts/members/JeffryHouser.html> My Company: <http://www.dot-com-it.com> My Podcast: <http://www.theflexshow.com> My Blog: <http://www.jeffryhouser.com> Andy Matthews wrote: ----- Excess quoted text cut - see Original Post for more ----- I thought you said that the database directory for development was a share network drive ("V:\something"). I took this to mean that your source code was local, but you had a database somewhere else. Was that assumption incorrect? Finding "Faces.db", makes me think that the database is in the application root directory. And if it is in the application root, then I'd expect that "app:/Faces.db" should also work. > Thanks for all of your time Jeffry, I really appreciate it. I hope I didn't > come across as rude, I'm just frustrated at the learning curve. Nope, not rude. > I feel > confident that with the stuff I'm learning on this project I'll be in good > shape for the rest of my Flex career. There is always more to learn, and I think that each project helps me on the next one. It's not a bad way to live. -- Jeffry Houser Flex, ColdFusion, AIR AIM: Reboog711 | Phone: 1-203-379-0773 -- Adobe Community Expert <http://www.adobe.com/communities/experts/members/JeffryHouser.html> My Company: <http://www.dot-com-it.com> My Podcast: <http://www.theflexshow.com> My Blog: <http://www.jeffryhouser.com> Jeffry... Yep...I think I didn't make myself clear, my fault. The db file is in the same directory as my mxml application files. Now that I understand how the file settings work, I'll see about using the app:/ pathing instead. Appreciated! Andy Matthews wrote: ----- Excess quoted text cut - see Original Post for more ----- I thought you said that the database directory for development was a share network drive ("V:\something"). I took this to mean that your source code was local, but you had a database somewhere else. Was that assumption incorrect? Finding "Faces.db", makes me think that the database is in the application root directory. And if it is in the application root, then I'd expect that "app:/Faces.db" should also work.
|
Mailing Lists
|
Latest Fusion Authority Articles
|
||||||