FREContext in Java

In Java FREContext is a class that you extend, which serves as a middleman between ActionScript and your native Java code.

Initializing FREContext

You have to implement two things for your FREContext class to be properly initialized.

The first one, of course, is the constructor. The second one is an implementation of getFunctions(): Continue Reading

How to send events from Java to ActionScript

When we looked at how native code and ActionScript communicate in a native extension, we saw that native code is mostly called and talked to and has a limited number of ways to respond or send data back. These are:

  1. Returning a FREResult object from a call to FREFunction.
  2. Using output parameters in a FREFunction.
  3. Sending an event to ActionScript.

In this article we are focusing on number 3: how events are sent from Java to ActionScript. Continue Reading

Keeping your C native code reusable and independent of AIR

When you make a native extension using the AIR C API, your native code tends to have two parts:

  • one that's concerned with exposing functionality in a way that AIR can call, in other words, dependent on the AIR C API;
  • functional part, which deals with the platform-specific stuff. This part of your code doesn't (and shouldn't) care about whether it's used in an AIR native extension, a purely native app or something else.

Ideally you want to keep the dependency between these two parts one-directional: the AIR-concerned part should depend on the functional part, but the functional part should not know about and depend on AIR. If you decide to reuse your, say camera or speech recognition functionality, in another project that's not AIR-related , you don't want to force that to include the AIR C API.

So, what happens if you need to dispatch an event from the functional part of your code? Say, the camera refused to start or the speech processor is ready with results and you want you alert AIR to this... Continue Reading

Do you need a copy of FlashRuntimeExtensions.h in your project?

If you've ended up on this page, you are probably already familiar with what goes into an ANE for iOS and an ANE for Mac OS. You also know that one of the main ingredients for these is the AIR SDK and its interface for these two platforms: the AIR C API.

Now, when you try to include that in your iOS or Mac OS native library, Xcode helpfully asks you whether you want the API's header file, FlashRuntimeExtensions.h, copied into your project. What should you do?

04 xcode project Continue Reading