Question

I have an AIR application that uses a native extension to create a series of dialogs the user navigates through. After the user navigates through the dialogs, I need the C/Objective-C side to notify the AIR app that the user finished as well as forward the series of choices the user made.

Is that possible?

IE: the C/ObjC equivalent of

public function evokeMyASMethod(choice0:int,choice1:int):Boolean
{
   // context opens the native extension to the AS3 side 
   var success:Boolean = context.call("myASMethod", choice0, choice1) as Boolean;
   return success;
}

An alternate solution is to start a timer in ActionScript that pings the native extension periodically to check whether the user has finished and fetch the values, but that seems so messy that I think I must be missing something obvious.

Any help is much appreciated. Thanks!

Was it helpful?

Solution

What you'll need to do is dispatch "status" events from the native code and then listen for them in your AS3 code.

So firstly in your AS3 code add a listener to your extension context:

context.addEventListener( StatusEvent.STATUS, onStatus);

private function onStatus( event:StatusEvent ):void
{
     trace( "code = " + event.code );
     trace( "level = " + event.level );
}

The code and level variables are two strings you can pass back from your native code. In your ObjC code you'll use the FREDispatchStatusEventAsync function to fire an event back to your AS3 code:

FREDispatchStatusEventAsync( yourFreContext, (const uint8_t*)"code", (const uint8_t*)"level" );

You just need to change the "code" and "level" strings as you see fit and process them in your onStatus handler.

More information here:

http://help.adobe.com/en_US/air/extensions/WSb464b1207c184b143961a5e412937b5d5c6-7ffc.html http://help.adobe.com/en_US/air/extensions/WSb464b1207c184b14-62b8e11f12937b86be4-7ff5.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top