Question

I can call native code(Android OS) from AIR application success, but i want to dispath event from native code to AIR application, how can i do that?

Thanks!

Was it helpful?

Solution

You can dispatch asynchronous events back to your actionscript application by using the dispatchStatusEventAsync function of the FREContext class. You'll need to store a reference to your FRE context somewhere and then call the function as below:

yourFREContext.dispatchStatusEventAsync( "anEventType", "some data" );

This will dispatch a status event to your actionscript context which you should add a listener to when you create your context on the actionscript side of your extension:

yourExtContext = ExtensionContext.createExtensionContext( "your.extension.id", null );
yourExtContext.addEventListener( StatusEvent.STATUS, extension_statusHandler, false, 0, true );

Then in your listener:

private function extension_statusHandler( event:StatusEvent ):void
{
    trace( event.code + "::" + event.level );
    // should trace from the above: anEventType::some data
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top