1

I am making a simple game, and have to have the properties of each level saved somewhere. I am a litlle familiar with php mysql, so I want to use SQL database.

I decided to write actionscript code that puts all the levels into the database, so I got confused a little: what is the point of putting it into the database since it has to be "stored" first anyway in variables? Just to access it comfortably?

What if I would be writing a cook book app? There should be some way to "import" the data to the apk without coding all that to run when app runs first after instalation, am I right? I know, there is a way to connect databases, but that sounds like "not the way".

Kuba hasn't forgotten Monica
  • 95,931
  • 16
  • 151
  • 313
prk_001
  • 361
  • 3
  • 17
  • Welcome to SO. Regarding your second question about importing, there is a discussion of how to ship a "stock" database (e.g., one containing all of your levels) with your app in the answers to this question: http://stackoverflow.com/questions/6120424/android-copy-database-from-asset-folder-but-only-get-an-empty-file – acj Sep 19 '13 at 19:44
  • thank you. I see I'll have to prepare database outside, and then import it to application, that makes sense. – prk_001 Sep 19 '13 at 20:25

1 Answers1

1

SQL in Adobe AIR is more meant for storing and easily accessing linear data. Think of a log of actions a user has performed, for example.

If you want easily accessible, persistent data of any format (e.g. local high scores or user name), using SharedObjects is much simpler. But it's meant for single instances of objects (and arrays of course), not for vast amounts of data.

If you just want some amount of static data accessible, you do not need a database. You can have some data file (XML, JSON, CSV, etc) that is easily editable and accessible embedded in your application and then read as needed. It's normally easier to use data in those formats, since editing them prior to packing is so much easier.

If you still want a large database pre-populated with data (e.g. a collection of data than can also be changed), you can just create a startup database file and use that instead.

In my experience, in most scenarios, needing a local SQL database is uncommon. Other's mileage may vary, of course (I don't build large corporate apps). My point is, I wouldn't be quick into jumping into using a SQL database just because of prior experience with MySQL. Having a static XML or JSON might solve the problem just as well, if not better. Consider that databases are probably handy primarily for fast queries of large amounts of data. Is this really what you need most?

If it serves as an example, on my own games, I normally just have a JSON file listing all the basic data I need. In a game I'm building right now, game.json has a list of all levels, and each level is stored in a file of its own, also a static file. To edit them, I just edit them on a text file and then run the game again - no crazy conversion or packing necessary.

zeh
  • 10,130
  • 3
  • 38
  • 56