Tuesday, October 27, 2009

Invoking AIR Application using Batch File

I am pretty sure if we are using a application which interacts with other application we need to invoke it using command propmt . Here is a simple way to invoke the application ..Also while invoking sometime we need to pass variables to the application as we do in flash vars..

First of all we need to set the environment variable for accessing the flex sdk in the system.. Add the following path to the sysytem path variable in your environment variable
C:\Program Files\Adobe\Flex Builder 3\sdks\3.0.0\bin

Note : It should point to the sdk's bin location in mycase it resided in C:/ Drive .

To Run the application we will use ADL(AIR Debug Launcher) using the following syntax:-
adl [-runtime runtime-directory] [-pubid publisher-id] [-nodebug] application.xml [root-directory] [-- arguments]

In my case i used the following line on my command prompt
F:\PROJECTS\Printing\bin>adl Printing-app.xml -- 321 0 active

First i reach to the point where my application bin folder reside(having compiled swf and application descriptor file) then using adl to invoke my application-app.xml

After the application-app.xml i added -- and then i gave three arguments separated my space.

In the application i can get the aruments as follows :-
We listen the following function in the application invoke="onInvoke(event)"

private function onInvoke(e:InvokeEvent):void
var arguments : ArrayCollection = new ArrayCollection( e.arguments );

Here i get all the arguments in a arraycollection.

No comments:

About Me