Create a Flex Library project using FDT

Next, create a Flex Library Project. The Flex Library project creates an ActionScript library file, which has the .swc file extension. To create a Flex Library Project in Powerflasher FDT follow these steps:

  1. Open Powerflasher FDT.
  2. On the File menu, click New > New FDT Project.
  3. In the Project name field, type nativeAS3.
  4. Choose a template for your new project field, select AIR > Desktop.
  5. Click Finish.
  6. Delete the contents of the src folder.

Add source code to your ActionScript library

Create a source file and add the Flex Library source code.

  1. Expand the nativeAS3 project.
  2. Right-click the src folder and click New > ActionScript Class.
  3. In the Package field, type com.example.
  4. In the Name field, type NativeAS3.
  5. Click Finish.
  6. Copy and paste the following code into the NativeAS3 file.
    package com.example
    {
        import flash.external.ExtensionContext;
        public class NativeAS3
        {
           private var _ctx:ExtensionContext;
           public function NativeAS3()
           {
                this._ctx = ExtensionContext.createExtensionContext
    				("com.example.NativeCode", null);
           }
        public function sayHello( ): Object 
           {
    
                var result:Object = this._ctx.call( "sayHello" );  
                return result;         
           }
       }     
     }
  7. Save your project:

The string com.example.NativeCode matches the name used on the native extension project created using the BlackBerry 10 Native SDK .

The code above implements the ActionScript portion of the methods sayHello(), which will call the shared object functions with the same name.

Generate SWC library using FDT

Generate a SWC file before you continue.

  1. Open PowerFlasher FDT.
  2. In the FDT explorer, right-click on nativeAS3.
  3. Select Run As > FDT SWC Library.