Creating your first application in FDT

The following steps help you create an application that prints a simple "Hello World!" example on the screen.

Create an FDT project

  1. In FDT, on the File menu, click New > New FDT Project.
  2. In the Project name field, type AIRHelloWorld.
  3. In the Choose a template for your new project section, select the AIR and BlackBerry PlayBook options.
  4. Click Finish.

Configure the build and packaging settings

  1. In the FDT Explorer view, right-click your FDT project.
  2. Click Properties.
  3. Expand FDT AIR Properties.
  4. Click BlackBerry.
  5. Select the Add Libraries to Classpath button.
  6. Click OK.

Force Adobe AIR runtime to version 3.1

Your FDT installation may not be using Adobe AIR runtime version 3.1. In order to compile and deploy your BlackBerry 10 application, you must force FDT to use version 3.1 of the Adobe AIR runtime.

  1. In the FDT Explorer view, right-click your ActionScript mobile project.
  2. Click Properties.
  3. Click FDT Compiler.
  4. In the Compiler arguments field, type -swf-version 14.
  5. Click OK.
  6. Expand FDT AIR Properties. Click BlackBerry.
  7. In the Deploy tab, in the Extra packaging option field, type -forceAirVersion 3.1.
  8. Click Apply.
  9. Click OK.

Clean your project

  1. On the Project menu, click Clean.
  2. On the Clean window, select the checkbox for your project.
  3. Click OK.

Update the project namespace

If you are creating a new project, you can skip this section.

If you are importing a project from a previous version of FDT, you must update the namespace of your project to the version of the AIR runtime used by your FDT installation.
  1. Open the <Project>-app.xml file.
  2. 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 your file.

Create your source code

In the FDT Explorer, expand the src folder. Open the AIRHelloWorld.as file in a text editor and replace the default code with the following code sample, where <your package name> is the package name defined in the new FDT project:

package <your package name>
{
	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);
		}
	}
}

Add an icon to your FDT project

Before you begin: Create an image in PNG format with a maximum resolution of 86 x 86 pixels.

  1. In FDT, in the FDT Explorer pane, in your project tree, right-click the src folder.
  2. Click Import.
  3. Expand General, and select File System.

  4. Click Next.
  5. Beside the From directory field, click Browse.
  6. Find the folder that contains your image.
  7. Click OK.
  8. Select the check box beside your image.

  9. Click Finish.

After you finish: You must update the bar-descriptor.xml file to notify the BlackBerry Tablet OS SDK for Adobe AIR that the image is the icon for your application.

  1. In the FDT Explorer view, in the bin folder for your project, double-click the bar-descriptor.xml file.
  2. In the text editor pane for bar-descriptor.xml, update the value of the image element to use your icon. Between the image elements, replace your_image.png with the name of your image file.
      <icon>
      	<image>your_image.png</image>
      </icon>
    
  3. On the File menu, click Save.

Update your bar-descriptor.xml configuration file

Before you can test, debug or sign your application on a BlackBerry PlayBook tablet, you need to update your bar-descriptor.xml file with the author and authorId values supplied by the RIM Signing Authority. To set up a debug token, and configure your computer for signing, use the deployment setup wizard. For more information on the deployment setup wizard, see Configure your development environment.

You do not need to complete these steps if you are testing your application on a BlackBerry Tablet Simulator. The BlackBerry Tablet Simulator does not require a debug token.

  1. In FDT, on the Window menu, click Preferences.
  2. In the Preferences window, expand FDT > Mobile > BlackBerry. Click Signing.
  3. In the Debug Tokens section, select your debug token, click Details.

  4. In the Debug Token Details window, copy your Author Id and Author values, click OK.

  5. In the FDT Explorer view, in the bin folder for your project, double-click the bar-descriptor.xml file.
  6. In the text editor pane for bar-descriptor.xml, update the value of the author element.
    author>Author Name</author>
    
  7. In the text editor pane for bar-descriptor.xml, update the value of the authorId element.
      <authorId>Author Id</authorId>
    
  8. On the File menu, click Save.

Next Steps

For more information on running, debuging and testing your application, see Using debug tokens.