QueTwo's Blog

thouoghts on telecommunications, programming, education and technology

Creating a Windows AIR Native Extension with Eclipse – Part 4

In this final of my 4-part video series, I show you how to import and use the ANE that we created in the last three videos.  We will be using Adobe Flash Builder 4.6 to import the ANE, and we will build a very quick sample application that will use the getTestString and getHelloWorld functions that we wrote in our native DLL written in C.

If you want a copy of all the final projects, you can download them here.  The ZIP file includes the CDT project, the compiled DLL, the ActionScript project, the compiled ANE and the project created in this fourth video.  Enjoy!

About these ads

20 responses to “Creating a Windows AIR Native Extension with Eclipse – Part 4

  1. James December 11, 2011 at 2:25 am

    Finally, thank for the detailed tutorials!

    There are quite a lot of steps to build a simple DLL, I would expected Adobe to make ANE more simple.

  2. Pingback: Cool Stuff with the Flash Platform – 12/16/2011 | Android Developers

  3. Stuart January 5, 2012 at 11:30 pm

    Great stuff – thank you Nick. Your style of teaching is refreshing!

  4. Francois Cournoyer January 10, 2012 at 4:34 pm

    I must have missed a step, but how did you make it so you could call your DLL functions from withing Flash Builder 4.6.0 without getting the “The extension context does not have a method with the name xxx”?

  5. akartmannkapit January 18, 2012 at 9:21 am

    Thanks a lot for sharing.
    I’ve been able to debug the extension doing this :
    - package the ane using the debug dll.
    - create a c/c++ attach to application debug configuration. Use the dll project, and point to adl.exe you’re using to debug the AIR application (should be C:\Program Files (x86)\Adobe\Adobe Flash Builder 4.6\sdks\4.6.0\bin\adl.exe).
    - First launch the air application in debug.
    - Then debug the “c/++ attach to application” configuration. It should show you a process list with one adl.exe.
    - Adl.exe will be suspended. Click on the process in debug view and choose resume.
    - Now you can add breakpoint in your c/c++ code.
    Hope this helps.

  6. Fernanda January 25, 2012 at 12:42 pm

    Thanks for the tutorial. But how do I create an ane using more than one dll? How do I do if the dlls are communication and depends on the other?

    • quetwo January 25, 2012 at 9:20 pm

      You don’t really do anything special. Only one DLL can be your entry point, but if it depends on other libraries, then that is fine. Package both DLLs into the ANE into the META-INF\ANE\Windows-x86\ directory.

      The Arduino ANE I created includes two DLLS (the main dll, and pthreads).

  7. Dmitry April 12, 2012 at 11:52 am

    This is awesome series of presentations about ANE. I’ve found it very educating and well made with lot of details which I’d personally spend tons of time to go over… So, thank you Nick!
    Few points I’d like to mention:
    1. Developing with MinGW has it’s own +/-. For the drawbacks I’d mention difficulty using standard Windows API. I’ve found this when tried using WMI classes and calls in C++ and MinGW obviously doesn’t support any of this, so…
    2. I’d suggest for the Author to mention there is a “CDT Visual C++ Support” plugin for Eclipse which integrates Visual Studio (Express) into the CDT. It installs support for VS includes and Microsoft SDK (if it’s presented).
    3. I found that developing an extension with C++ actually requires declaring your functions in extension’s Application.h header file. I think this is not the case if you use C. But with C++ I wasn’t able to call my functions if they are not declared in the header file.

    Keep it up Nick!

    • quetwo April 14, 2012 at 8:59 am

      Thanks. I’ve been contemplating putting up a more comprehensive ANE training course about all these. You are right — if you need to use anything Windows GDI, WMI, .NET, etc. using MiniGW is a real pain in the rear. There is quite a bit of documentation from Adobe (including two recordings on Adobe TV) on how to build ANEs with Visual Studio. I always though it was crazy that they supposedly required VS in order to make them, which is where this video series came from. I just couldn’t afford VS, nor did I really want it on my machine here at home (I use it at work for some projects and really do like it — it just makes my machine noticeably slow).

      • Mike June 1, 2012 at 8:51 am

        Please do. This is what will make or break AS3 as it moves forward. For those of us with time and projects invested in AIR, this is the feature that will keep AIR viable for a long time to come. It is also the least documented and most confusing aspect of AIR. Your tutorials are great and easy to follow. I will be following your blog and hoping for more on this.

  8. Dmitry April 12, 2012 at 11:58 am

    Btw. I did too got: “The extension context does not have a method with the name xxx” message. But since I was using C++ for my example, I though this maybe has something to do with C/C++ specifics. However ones I added declarations for the functions into header file, i was able to call the functions just fine:

    extern “C” __declspec(dllexport) void initializer(void** extData, FREContextInitializer* ctxInitializer, FREContextFinalizer* ctxFinalizer);
    extern “C” __declspec(dllexport) void finalizer(void* extData);

    extern “C” __declspec(dllexport) FREObject isSupported(FREContext ctx, void* funcData, uint32_t argc, FREObject argv[]);
    extern “C” __declspec(dllexport) FREObject getTextString(FREContext ctx, void* funcData, uint32_t argc, FREObject argv[]);

    • quetwo April 14, 2012 at 8:55 am

      Yeah, if you use C++, the namespace dictionary gets mangled unless you do the extern “C” in front of those functions. Unfortunately, it is not the same issue that people have been running across where the DLL fails to load and they get “method connect() not found” or something along those lines… That is an issue with Flash Builder, and the way it is passing the command-line strings to ADL.

  9. Mike June 13, 2012 at 4:56 pm

    I’m working on a project that needs to make use of a .NET dll. I can’t seem to figure out how to set up the project. Following this series, I was able to get a project set up either as a c project or a cpp (using extern “C”) that compiles with the FlashRuntimeExtensions, but I can’t seem to figure out how to incorporate the .NET dll. In the documentation for the DLL I need to use, I have instructions for creating a .tlb file, but I can’t seem to get a valid reference to it in my project. Any help would be greatly appreciated.

  10. Mike June 13, 2012 at 5:03 pm

    I’m working on a project that needs to wrap a .NET DLL in an ANE. I can’t seem to get the project set up to let me code this way. The documentation for the dll that I’m working with did give me instructions to create a .tlb for working with unmanaged code, which I followed, but I can’t seem to reference that in my project. I followed your series here and found it very helpful in setting up my project to work with the FlashRuntimeExtensions, but now I need to know how to reference a .tlb for a dll in a c or cpp project. Any suggestions?

  11. saran July 2, 2012 at 2:51 pm

    is it possible to create a captive installer with ANE?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

Join 27 other followers

%d bloggers like this: