views:

470

answers:

2

I'd like to reference an external configuration (e.g., *.ini) file that will allow me to set configuration variables for each deployment of my Air application. Unfortunately, I haven't been able to find any information on the best way to approach this problem.

With that being said, does anyone have any advice on how to make this happen?

+1  A: 

I dont know if there is an air centric way of making this happen. I haven't found any good class i the api docs. If you got a lot of configuration options there might be an idea to look for an existing library that can help you. But if you just need to store some simple settings i would just create a small xml file and parse it with E4X.

It might be possible to jam it inside the application descriptor but it doesn't feel like a good solution if you want someone to manually change some settings.

Tjelle
I think we're on the right track with the XML file. How would I reference it from within my app?
Huuuze
+2  A: 

Here's the implementation of the small xml idea:

var file:File = File.applicationDirectory.resolvePath( "config.xml" ); var stream:FileStream = new FileStream();

stream.open( file, FileMode.READ ); config = new XML( stream.readUTFBytes( stream.bytesAvailable )); stream.close();

Just place the config.xml file in your src directory, it will appear in the installed directory when the release package gets installed. I made config a public var on my main application, so I can just do Application.application.config.someOption from anywhere in my project.

Lucki
This really helps with a project I'm doing at work. Thanks!
Huuuze