Adobe AIR Native Extensions with Native iOS UI

Last week I demo’d an Adobe AIR native extension that displayed a native MKMapKit view in an AIR application. Here is how to integrate any UIView object.

First you need a reference to the native applications view hierarchy. You can grab that like so:

id delegate = [[UIApplication sharedApplication] delegate];
UIWindow *window = [delegate window];</code></p>

Once you have the window object you can add any sub view to it that you want. Here’s an example of adding a MKMapKit view.

MKMapView *map = [[MKMapView alloc] initWithFrame:CGRectMake(0, 0, 480, 320)];
[window addSubview:map];

That’s it! This code can go pretty much any where in your native extension. Keep in mind that these native views are not part of the AIR application’s display list, so they always render on top of the AIR application.

I’ll demo how to draw a native view to an AS3 BitmapData object in a future post. This allows you to integrate the native views with AIR’s display list, but at the cost of loosing all native interaction.

Tagged:

Flash, ActionScript-3, development, code, programming, How to

Comments

Comment functionality has been disabled. Contact me on Twitter.

Nathan Daniel said:

I’m wondering if the native extension you’re using is available (free or paid). I’m currently working on the same thing; would rather not reinvent the wheel. :)

Tyler Egeto said:

Hi Nathan, unfortunately I do not have the rights provide the source code for this ANE. Adding the src code above to any “hello world” example will get you 95% of the way there however.

Gennaro said:

Hi! Can you help me to create a Google Maps Native Exstension? Thanks.

Meet said:

Hi Tyler,

The project is available now at http://code.google.com/p/air-maps-ane/ along with source and binary files. Do try it out !!!

And thanks for this post to keep others going in the meantime :)

Thanks, Meet

Tyler Egeto said:

Thanks Meet! Looks fantastic.

Kevin Sandapen said:

Hi Tyler, I ran into a very weird issue. After calling a native window pop-up, i lose all interaction with my flash content..as if the application has lost focus..Did you ran into something similar? I’m testing on iOS6, Air3.4.

Thanks, Kev.

Tyler Egeto said:

Hi Kevin, I don’t recall seeing that issue. I am doing some native stuff with iOS 6 without any issues. I wonder if a transparent iOS view is being rendered above your Flash content?

Recent & Popular Articles

Browse All >