Search code examples
apache-flexair

How to use ExtensionContext in Flash Builder 4.6?


I'm using flash.external.ExtensionContext so that I can call native iOS functions within SWF files.

Following the guidelines from

http://www.lorenzonuvoletta.com/how-to-create-your-own-ane-for-ios-using-adobe-air/

I've got the SWC and ANE files.

Now I create an AIR app and using the following lines to call the native function (only to get a 'hello world' string):

private function onCreate() {
    var inst:ANEHellowWorld = ANEHelloWorld.instance;
    var str:String = inst.helloWorld(); // fails since the extContext member is null

    // try it directly
    var extContext:ExtensionContext = ExtensionContext.createExtensionContext("com.lorenzonuvoletta.helloworld", "net");
    var str2:String = extContext.call("helloWorld") as String; // still null object
}

Why createExtensionContext always return null? And another question, how can I access ExtensionContext in normal flex projects? It seems to be no flash.external.ExtensionContext at all.


Solution

  • Now I've learned that Native Extension is only available in Flex Mobile Projects. And for the null-returning problem, the .ane file should be added to the Project->Properties->Flex Build Path, in Native Extension Path. Just hope the info help some rookie Flex users like me. Never mind.