Creating your first application with the Command Line Tools

The following steps in help you create a simple "Hello World!" example that demonstrates use of an application-modal dialog to prompt for the user's name and echo it in a greeting.

In a text editor, paste the following code sample to create an Adobe ActionScript application and save the file as AIRHelloWorld.as:

		package
		{
			import flash.display.Sprite;
			import flash.display.StageAlign;
			import flash.display.StageScaleMode;
			import qnx.fuse.ui.text.Label;
			[SWF(height="600", width="1024", frameRate="60",
			backgroundColor="#FFFFFF")]

			public class AIRHelloWorld extends Sprite
			{
				public function AIRHelloWorld()
				{

					// support autoOrients
					stage.align = StageAlign.TOP_LEFT;
					stage.scaleMode = StageScaleMode.NO_SCALE;

					//Initialize the UI
					initializeUI();
				}

				private function initializeUI():void
				{
					// create a label
					var myLabel:Label = new Label();

					// Define a label width
					myLabel.width = 200;

					// set the label to appear at the center of the
					// screen
					myLabel.x =
						(stage.stageWidth - myLabel.width) /2;
					myLabel.y =
						(stage.stageHeight - myLabel.height) /2;

					// set the label text to "Hello World!"
					myLabel.text = "Hello World!";

					// add the label to the screen
					addChild(myLabel);
				}
			}
}

Create an XML configuration file for your application icon

The following steps demonstrate how to create an XML configuration file that instructs the BlackBerry Tablet OS to use an image that you create as the icon for your application.

  1. In a text editor, paste the following XML markup.

    <qnx>
      <icon>
      	<image>your_image.png</image>
      </icon>
    </qnx>

  2. Between the image elements, replace <your_image>.png with the name of your image file.
  3. Save the file with the name bar-descriptor.xml in the same folder as your application.

Add an icon to your Adobe ActionScript project

You can add an image to your project to use as the icon for your Adobe ActionScript project.

  1. Create an image in PNG format with a maximum resolution of 86 x 86 pixels.
  2. Save the image in the same folder as your application.
  3. Create an XML configuration file to notify the BlackBerry Tablet OS that the image is the icon for your application.

Compile your application

Once you have created your ActionScript file, you need to compile the application into a *.swf file.

Use the amxmlc tool to compile your application using the following command:

amxmlc AIRHelloWorld.as

When this command is completed successfully, you will find a AIRHelloWorld.swf file in your project directory.

This command assumes that you have added the bin subfolder located where you installed the BlackBerry 10 SDK to the PATH environment variable for your operating system.

Operating System Default location of the BlackBerry Tablet OS SDK for Adobe AIR
Windows) \Program Files\Research In Motion\
Mac /Developer/SDKs/Research In Motion/

Create an XML configuration file

The following steps demonstrate how to create an XML configuration file.

  1. In a text editor, paste the following XML markup.

    To include AIR Native Extensions (ANE) into your application, you must include the package in the <extensionsID> tag. For this application, you will use the QNXSkins ANE.

    <?xml version="1.0" encoding="utf-8" standalone="no"?>
    		<application xmlns="http://ns.adobe.com/air/application/3.1">
    		        <id>net.example.test</id>
    		        <filename>AIRHelloWorld</filename>
    		       <name>AirHelloWorld</name>
    		        <versionNumber>1.0.0</versionNumber>
    		         <copyright>Example Inc.</copyright>
    		        <initialWindow>
    		                <content>AIRHelloWorld.swf</content>
    		        </initialWindow>
    		      <extensions>
    			       <extensionID>qnx.fuse.ui.skins.QNXSkins</extensionID>
    		    	</extensions>
    		</application>
  2. Update the namespace of your project to the version of the AIR runtime you are using. In the <application> element, set the XML namespace to the version of your AIR runtime.

    For example, using AIR runtime 3.1:

    <application xmlns="http://ns.adobe.com/air/application/3.1">

  3. Save the file with the name AIRHelloWorld-app.xml in the same folder as your application.

    Make sure that this file name matches the name of your ActionScript file.

Next Steps

To set up a run or debug configuration, and test your application, see Testing your application.