Wednesday, May 19, 2010

Developing simple Application in AdobeAIR with HTML and Javascript

Download Adobe AIR and Adobe AIR SDK from Adobe Site.
Extract the Adobe AIR SDK in that you will find bin directory.
Add this bin directory as environment variable.i.e if you extracted the Adobe AIR SDK in C:\
Add the Environment variable as C:\AdobeAIRSDK\bin

Create the application's Directory Structure Like This
/appname/
/appname/source/
/appname/source/icons/
/appname/build/

Now its time to create Application Descriptior.
Your application descriptor is an XML file that sets some properties for your application.
Let's call this file application.xml and place it in /appname/source/
\<\application xmlns="http://ns.adobe.com/air/application/1.0"\>
\<\id\>com.example.appname \<\/id\>
\<\version\>1.0 \<\/version\>
\<\filename\>AppName \<\/filename\>
\<\initialwindow\>
\<\content\>index.html \<\/content\>
\<\visible\>true \<\/visible\>
\<\width\>600\<\/width\>
\<\height\>600\<\/height\>
\<\/initialwindow\>
\<\/application\>

The next step can be as detailed as you like, but really all you need to do is create an index.html file.

\<\html\>\
\<\head\>\
\<\title\>\My Window Title\<\/title\>\
\<\/head\>\
\<\body\>\
\<\h1\>\Hello World\<\/h1\>\
\<\/body\>\
\<\/html\>\

Now you can test your application.

To do this Open up a command prompt, or shell and navigate to /appname/source/ then run the following command:

adl application.xml

As I said before if you add the bin directory to environment variable you can run the above command otherwise instead of adl give the complete path of the adl.

Now you can deploy your application.

Before Deploy we need to get the certificate from the adobe.
Chances are you really just want to show your new application to a few people, and not the entire world. If that's the case then you can easily create a self signed certificate. It is important that the Certificate is not placed in your source directory, so let's place it in the root of our application: /appname/

"adt -certificate -cn SelfSign -ou Dev -o "Example" -c US 2048-RSA cert.pfx password"

after we certificate generated we can deploy the application.

Change directory back to source directory and run the following command.

"adt -package -storetype pkcs12 -keystore ../cert.pfx ../build/AirTest.air application.xml . "

it will ask for password,enter the password. Your application will be deployed and located in build directory.

That’s it you have developed an application in Adobe AIR.