28.04.2016 Views

Adobe AIR Building Apps

Adobe AIR Building Apps AS3 Actionscript

Adobe AIR Building Apps AS3 Actionscript

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

BUILDING ADOBE <strong>AIR</strong> APPLICATIONS<br />

Creating your first <strong>AIR</strong> application<br />

41<br />

Compile the application<br />

Before you can run and debug the application, compile the MXML code into a SWF file using the amxmlc compiler.<br />

The amxmlc compiler can be found in the bin directory of the Flex SDK. If desired, you can set the path environment<br />

of your computer to include the Flex SDK bin directory. Setting the path makes it easier to run the utilities on the<br />

command line.<br />

1 Open a command shell or a terminal and navigate to the project folder of your <strong>AIR</strong> application.<br />

2 Enter the following command:<br />

amxmlc HelloWorld.as<br />

Running amxmlc produces HelloWorld.swf, which contains the compiled code of the application.<br />

Note: If the application does not compile, fix syntax or spelling errors. Errors and warnings are displayed in the console<br />

window used to run the amxmlc compiler.<br />

For more information, see “Compiling MXML and ActionScript source files for <strong>AIR</strong>” on page 149.<br />

Test the application<br />

To run and test the application from the command line, use the <strong>AIR</strong> Debug Launcher (ADL) to launch the application<br />

using its application descriptor file. (ADL can be found in the bin directory of the <strong>AIR</strong> and Flex SDKs.)<br />

❖ From the command prompt, enter the following command:<br />

adl HelloWorld-app.xml<br />

For more information, see “Device simulation using ADL” on page 96.<br />

Create the APK package file<br />

When your application runs successfully, you can use the ADT utility to package the application into an APK package<br />

file. An APK package file is the native Android application file format, which you can distribute to your users.<br />

All Android applications must be signed. Unlike <strong>AIR</strong> files, it customary to sign Android apps with a self-signed<br />

certificate. The Android operating system does not attempt to establish the identity of the application developer. You<br />

can use a certificate generated by ADT to sign Android packages. Certificates used for apps submitted to the Android<br />

market must have a validity period of at least 25 years.<br />

Generate a self-signed certificate and key pair<br />

❖ From the command prompt, enter the following command (the ADT executable can be found in the bin directory<br />

of the Flex SDK):<br />

adt -certificate -validityPeriod 25 -cn SelfSigned 1024-RSA sampleCert.pfx samplePassword<br />

This example uses the minimum number of attributes that can be set for a certificate. The key type must be either<br />

1024-RSA or 2048-RSA (see the “ADT certificate command” on page 166).<br />

Create the <strong>AIR</strong> package<br />

❖ From the command prompt, enter the following command (on a single line):<br />

adt -package -target apk -storetype pkcs12 -keystore sampleCert.p12 HelloWorld.apk<br />

HelloWorld-app.xml HelloWorld.swf<br />

You will be prompted for the keystore file password. Type the password and press Enter.<br />

For more information, see “Packaging a mobile <strong>AIR</strong> application” on page 89.<br />

Last updated 2/22/2016

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!