| Home | Tutorials | Forums | Articles | Blogs | Movies | Library | Employment | Press | Buy templates |
|
|
#1 |
|
Registered User
Join Date: Jan 2007
Posts: 30
|
First off, i am really confused on how to make properties global in a flex app and this is probably why i can't grasp this concept. But i have created a singleton class to instantiate a database connection. When i try to access the connection through another view AIR throws me an error saying "database must be open to perform this operation". But i did open it at the begining of the app, and in my singleton, if it hasn't been already initialized, then it will initialize it. But this tells me the class knows its already open otherwise i wouldn't get that error. So i am obviously not accessing it properly. What am i missing? How do i access my static property in other components after it has been inistantiated?
Here is my singleton class ActionScript Code:
My main application: ActionScript Code:
Then the InventoryReceiving.mxml: ActionScript Code:
|
|
|
|
|
|
#2 |
|
lala
Join Date: Feb 2002
Location: on the road
Posts: 2,859
|
what version of AIR?
|
|
|
|
|
|
|
|
|
#3 |
|
Registered User
Join Date: Jan 2007
Posts: 30
|
Good question. I dont even know how to find that out. But i did download it less than a week ago, so it should be the current version. I did get it to work correctly though by adding a getter which i could reference.
The modified part of the class looks like this: ActionScript Code:
And now i reference by calling the database property DatabaseConnector.getInstance().database If there is a more efficient way of doing this, please don't hold back. Another thing. The database i am accessing i created using SQLiteManager but AIR doesn't seem to like it. I don't get any errors connecting to it, but i presume this is because my code creates a new database if one doesn't already exist. So this would explain when i try to access a table in the generated db that i receive an error saying the table cannot be found. I would like to be able to include a separate database with my app, just so its easier to for people to make backups or be able to access it through other applications. Any ideas on why i am unable to use a pre-defined database? Thanks!!! |
|
|
|
|
|
#4 |
|
lala
Join Date: Feb 2002
Location: on the road
Posts: 2,859
|
i have not used the sqlite yet, i asked some people i work with about their experience with it but they could not say for certain.
i think a singleton is a very valid way of doing this |
|
|
|
|
|
#5 |
|
Registered User
Join Date: Jan 2007
Posts: 30
|
I've figured it out. It didnt like my pre built database because i was trying to access it via the applicationStorageDirectory rather than a user file directory such as desktopDirectory. now it works.
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Flash Remoting with Perl | dopefries | Flash Remoting | 3 | 02-17-2007 02:42 PM |
| crossdomain globals... big problem with class static variables ! | _marabout | ActionScript 2.0 | 2 | 07-21-2006 03:07 PM |
| scope problem in a class | hbd | ActionScript 2.0 | 4 | 08-31-2005 02:10 PM |
| Skinning components with embedded components | epeace | Components | 5 | 06-16-2005 09:35 PM |
| problem accesing instance properties defined in a class | glantucan | ActionScript 2.0 | 3 | 05-06-2005 02:54 PM |