Skip to main content
Participating Frequently
June 1, 2011
Question

How to create a more general install package for an AIR app?

  • June 1, 2011
  • 1 reply
  • 528 views

Hi,

I have been using the ADT to compile an exe of my AIR app along with some other files I want to distribute. Problem is, I would like to do more general install actions (e.g. copy a bunch of files to the users Documents directory, copy a file to the local store, install fonts etc). Right now I achieve some of these by copying stuff from the application directory on the first run, but that is rather kludgy. Currently I am looking at using InstallShield or InstallAnywhere to do what I want out of the can, but I thought I'd see if anyone has some more AIR-friendly suggestions...

Thanks!

This topic has been closed for replies.

1 reply

June 16, 2011

Did you find a solution for this ? im struggeling with a somewhat similar problem..

dargreAuthor
Participating Frequently
June 16, 2011

In my case I managed to work around the issues we were having by doing a configuration pass on the first run of the app. That means I had to basically put all the data I needed in my assets directory using the ADT compiler, then determine if it is a first run as follows:


var locationPrefsObj:SharedObject = SharedObject.getLocal("PrefsObj");


if ( !locationPrefsObj.data.hasOwnProperty("appCreatedDate")
|| ( locationPrefsObj.data.appCreatedDate != File.applicationDirectory.creationDate.toString() ) )

{

     firstRun();

}


else {
     initConfig();


// initialize an existing config

}

The firstRun function will obviously be very bespoke, but you need to set the SharedObject at the end of it to make sure it doesn't get called every time.


// this function is only run straight after an install

private function firstRun():void {

     var success:Boolean = false;

     // do your first run stuff here and mark success=true if you are happy   

     if ( success ) {

          // set the appCreatedDate - then a future install can identify dirt left by the previous install

          var locationPrefsObj:SharedObject = SharedObject.getLocal("PrefsObj");

          locationPrefsObj.data.appCreatedDate = File.applicationDirectory.creationDate.toString();

          locationPrefsObj.flush();

     }


}

Other gotchas I hit:

(1) You can copy things from the assets folder no problem, but to move or delete anything (so as not to leave lots of extra stuff hanging around), you need to (a) run with administrator privileges on Vista and w7 (the elevation happens automatically if you leave the "Run after install" box checked on an ADT install), and (b) work around the Flash security model that says you can't delete anything from a subdirectory of Program Files under any circumstances. I got around this by something like:

// delete a file

new File(File.applicationDirectory.resolvePath("assets/fileToBeDeleted").nativePath).deleteFile();

It's a bit nasty as it violates the security model, but until ADT lets you put stuff in two install locations I can't see another way to clean up the install properly.

(2) I tried to install fonts (using VB and other stuff), but it is a real mess - the models in all different flavours of Windows seem to be different. I gave up as our software could get around it another way ...

Hope that helps!