Step 1: Download the AIR sdk from adobe labs : http://labs.adobe.com/downloads/airsdk.html and unzip it
Step 2 : Download the tutorial sample files here and unzip them
Step 3: Create your application and an AIR descriptor file or use the example files
To keep this short, just compile the application (whether it's flash or flex - doesn't matter) so you have a swf and take and edit the descriptor-template.xml file (Specifies parameters for identifying, installing, and launching AIR applications) from the template dir in the SDK. More info on setting up the descriptor-file : here. Make sure to set the main swf of the application, otherwise no swf will be loaded in your app window. In this tutorial, you can use example.swf and example-app.xml from the template folder.
Step 4: Configure your adt.bat file
You can find the bat-file in the SDK in the bin-folder. You can copy the bin and lib folder from the SDK to the template folder. In order to build the AIR-file (either local or on the server) we need to setup our bat-file. The file looks for the moment like this : @java -jar "%~dp0\..\lib\adt.jar" %* You can just right click and choose "Edit" to open the bat file in notepad.
First make sure you have java installed (if you don't, get it for free here : http://www.java.com/en/download). This is the first thing we need to set : our path to the java executable. Search for the path on your pc to the java.exe, it will look like this : "C:\Program Files\Java\jre1.6.0_03\bin\java.exe"
Now we need to add -jar and after that enter the path to the jar-file which is part of the SDK that needs to be built . So we add "..\lib\adt.jar" to our bat-file. So now we have the first part, we still need to set a bunch of parameters. We always put a space between all parameters and values.
Package and sign the AIR file in one step, with the parameter -package and the following syntax:
-keystore path to certificate (.p12 file or pfx-file)
-storepass password for certificate
Ok we'll hold it here for a moment. What the hell is digitally signing an AIR-file dude and why the hell would I do that? To little time to explain it all here. It's pretty complex, I'll try to post a tutorial on this matter maybe later. For this tutorial you can use the example.pfx file (password: example) from the download template. Now, let's move on.
Next up, path and name for the AIR-file to compile:
Followed by the path to our previous made xml descriptor file:
Now we need to add the final and maybe most important part of this build-file. We need to specifiy which files/folder that need to be packaged. We have an extra help paramater which is -C. This parameter followed by a path will change the working directory, so we add -C "C:\Users\user\Desktop\template". Now we can add files/folders relative to this working directory e.g. assets, icons and don't you forget to add your swf !!! This is what this whole thing is about after all, your application. So this part is now : -C "D:\Desktop\template" icons example.swf
Tip: don't include your certificate in the package, the certificate is only meant for signing the AIR-file. Don't spread it around.
Step 5: Run the .bat file and run your AIR application
If everything is set up fine, this should be the content of your bat-file right now:
"C:\Program Files\Java\jre1.5.0_10\bin\java.exe" -jar "..\lib\adt.jar" -package -storetype pkcs12 -keystore "D:\Desktop\template\example.pfx" -storepass example "D:\Desktop\Example.air" "D:\Desktop\template\example-app.xml" -C "D:\Desktop\template" icons example.swf
After that we can add "-pause" which will freeze the command screen so we can see what eventually went wrong.
We are ready to build our AIR-file, just double-click your adt.bat file and wait for the magic to happen. If the magic doesn't happen, there will probably be something wrong (lol! Hmm..probably not a good time for jokes right now). Just check your file again for little errors like forgetting a " before/after a value and make sure you use full paths as much as possible. It probably will go wrong a few times due to such errors. Don't panic and stay calm! Evacuate women and children first. J/k just read through this thing again and compare your file with the above, I'm sure with a few trial and errors you will find your mistake. If you don't, feel free to send me a mail, I will help you in every way that I can . If the AIR-file is built, just double click it to install your application. If your application doesn't work, it is NOT MY FAULT. Only if your swf doesn't load up, you can blame me (well, maybe just a little). Just check your descriptor xml file and be sure to add your swf to the package.
Now you probably ask yourself why should I build an AIR file with the command line? I can just export an AIR file with flash/flex, right? And it's easy cheesy peasy. Well, you are totally right. Oh maaaaan! I read through this whole thing just to hear that I can do the same with 3 clicks in flash/flex? Yea, you did! L! No, building with the command line has the big advantage that we now can build an AIR file on the server/on the fly. With a little .net module, we can change our parameters in the bat file (read:change our content) and build a specific AIR file with specific online/uploaded content. We at indie group made a lil example of what's possible with this. You can read more about this later.