Creating your first application with the Command Line Tools

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

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;
	
	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);	
		}
	}
}
comments powered by Disqus