Create a Flex Library project using Flash Builder

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 Adobe Flash Builder, follow these steps:

  1. Open Flash Builder.
  2. On the File menu, click New > Flex Library Project.
  3. In the Project name field, type nativeAS3.
  4. Select Mobile Library, and leave all other options with their default values.
  5. Click Finish.

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.