Create the AIR sample application

The following sample Adobe AIR application is a simple application that uses the ANE you created. The sample application consists of a simple screen with a Hello button.

For more information on creating an AIR project, see Getting Started.

  1. Create an AIR application and call it UsingANE.
  2. Add your ANE (com.example.NativeAS3) and the QNXSkins.ane to your application.
    Operating System Default location of the QNXSkins.ane
    Windows (x64) \Program Files (x86)\Research In Motion\blackberry-tablet-sdk-<version>\frameworks\libs\qnx\ane\
    Windows (x86) \Program Files\Research In Motion\blackberry-tablet-sdk-<version>\frameworks\libs\qnx\ane\
    Mac /Applications/SDKs/Research In Motion/blackberry-tablet-sdk-<version>/ frameworks/libs/qnx/ane/
    • For more information on adding ANEs to your application using Adobe Flash Builder, see Add an ANE using Flash Builder.
    • By default, FDT includes the built-in ANEs (including QNXSkins.ane). To add a custom ANE to your application using FDT, see Add an ANE using FDT.
    • To add ANE to your application using the command line tools, you must include your ANE when you package your application. For more information, see Test applications using the command line.
  3. Copy the following code into the main source file:
    * A simple example that demonstrates use of AIR native extension
    * by invoking the native code, getting the printf output from the
    * native code, and display on the screen.
    	import com.example.NativeAS3;
    	import flash.display.Sprite;
    	import flash.text.TextFormat;
    	import flash.text.TextFormatAlign;
    	import qnx.fuse.ui.buttons.LabelButton;
    	import qnx.fuse.ui.text.Label;
    	[SWF(height="1280", width="768", frameRate="60", 
    	public class UsingANE extends Sprite
    		private var helloLabel:Label;
    		private var helloButton:LabelButton;
    		private var extension:Object;
    		public function UsingANE()
    			/* A button to run native code. */
    			helloButton = new LabelButton();
    			helloButton.label = "Hello";
    			helloButton.width = 150;
    			helloButton.x = 
    				stage.stageWidth / 2 - helloButton.width / 2;
    			helloButton.y = stage.stageHeight / 2;
    			/* A label in which to show the 
    				hello greeting. */
    			helloLabel = new Label();
    			helloLabel.width = 800;
    			helloLabel.height = 30;
    			helloLabel.x = 
    				(stage.stageWidth - helloLabel.width) / 2;
    			helloLabel.y = helloButton.y - 60;
    			/* Listen for a click on the button. */
    				(MouseEvent.CLICK, onHelloButtonClick);
    			stage.nativeWindow.visible = true;
    		private function 
    			this.extension = new NativeAS3();
    			var out:String =
    				new String(this.extension.sayHello());
    			helloLabel.text = out;
  4. Update your project XML files.
    1. Modify the <extensions> tag in the UsingANE-app.xml file to indicate that the native extension called com.example.NativeAS3 is available for use.

      Adobe Flash Builder automatically adds the <extension> information when you add an ANE file using the steps outlined in Add an ANE using Flash Builder.

    2. Modify the <action> tag to the bar-descriptor.xml file to be able to run native code from an AIR application.
      <action system="true">run_air_native</action>
  5. On the File menu, click Save.
  6. Deploy and test your application on a BlackBerry Device or on the BlackBerry simulator. For more information on testing and deploying your application, see Testing & Debugging.