What goes into an AIR Native Extension for Windows?

Opt In Image
Early bird offer on the ANE eBooks

 

Buy any Easy Native Extensions 2nd Edition package and get our $99 iOS + Android ANE Template completely free before the end of June 2015.

 

 

  • step-by-step guide to making your iOS extension in under an hour
  • library for data conversion between ActionScript and native code
  • tutorials
  • infographics
  • code included

So, you know what an AIR Native Extension (ANE) is and how it fits in your app. Next, you are contemplating an AIR Native Extension for Windows, while everyone is going crazy about iOS and Android.

Well, good for you! For one, it’s a lot more straightforward to debug the native part of your ANE code on Windows than on the other platforms. I’ll show you how in a future post.

For now, let’s focus on what you have to work with and what you need to do.

The two components that you have to make yourself are:

  • an AIR library, compiled as a .swf file;
  • a native C, or C++ library, compiled as a .dll (Dynamic-link library).

The third component is provided for you and it helps your two libraries talk to one another:

  • the AIR C API for Windows.

The AIR library

Your AIR library is a Flex library project, which contains an instance of flash.external.ExtensionContext. ExtensionContext is the class that provides an ActionScript interface for you to make calls to and receive messages from your DLL.

The AIR C API

The AIR C API is the layer that sits between your ActionScript and C/C++ code. It translates the ActionScript calls you make to ExtensionContext into C and allows you to send events and data from C back to ActionScript.

The AIR C API is part of Adobe’s AIR SDK and is implemented as a static library: FlashRuntimeExtensions.lib. This and FlashRuntimeExtensions.h header are the two files you will have to include in your native library (see below).

The native library

Your native library will be a DLL that uses the AIR C API, which I’ve put in red on the diagram below. It can also include any number of Windows SDK or third party libraries.

Windows native library

The ANE package

Once you have an AIR library and a DLL which uses the AIR C API, you package them together into an .ANE file, using Adobe’s ADT tool. I’ll show you how in a future post.

Windows ANE structure

What else?

Over to you

Are you a seasoned Windows developer who is looking into Adobe AIR and cross-platform programming? Or are you an ActionScript fan who would like to dig deeper on Windows?

What would be useful for you to learn next? Tell us in the comments below.


Warning: count(): Parameter must be an array or an object that implements Countable in /home/easyna6/public_html/easynativeextensions_wp/wp-includes/class-wp-comment-query.php on line 399

Comments

  1. mostafa

    Hi,
    thanks for the complete and simple tutorials.
    I have a question, suppose I a have a third party library (ArioSdk.dll) and it’s header file (Ario.h).
    My main dll file (myExtension.dll) depends on the ArioSdk.dll.
    Where should I put the ArioSdk.dll to package the ANE file?
    I put it beside MyExtension.dll and package it. so in the final ANE file both files exist. but in runtime it returns error “ArgumentError: Error #3500: The extension context does not have a method with the name IsSupportedAsynch.”, But If I only remove the dependency to Ario.dll, and muck the related function with dummy codes, Air application can call the method successfully.
    Do you have any idea how to address the 3rd party library in ANE file?

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">