iOS 6, Adobe Air (3.4 upgrade) and drawWithQuality

iOS 6 + Adobe Air

The all new shiny and powerful iOS 6 arrived recently, allowing developers to add even more cool features to their applications. But what does it mean for those who develop iOS apps using Adobe AIR?

Well, we found out it the hard way. Our app that was built using Adobe 3.1 SDK just stopped working for those users who upgraded their devices. Unfortunately there is no way to limit the app distribution to older iOS versions (4 and 5) so we had to scramble to see what can be done.

Good thing that the new Adobe AIR 3.4 SDK recently arrived and it does support iOS6. They also added a number of awesome features and finally bundled AIR SDK with Flex SDK, so you don’t have to download them from separate sources and do all the manual work to merge. That bundled version can be downloaded here.

The upgrade is pretty simple. You need to reference the new SDK in project dependencies, update you app descriptor.xml with this line (replacing the old one):

xmlns=”http://ns.adobe.com/air/application/3.4″>

and in compiler options specify the following:

-swf-version=17

After that you can compile it and run on your Android and iOS devices!

There are few gotchas that came with new features, however…

Our app Sketch Guess Free was written for the GPU render mode and a variety resolutions. To make it work we are using vector assets that are drawn to bitmaps at run-time. While any mobile application should run at StageQuality.LOW (because its times faster) you cannot draw at this quality because the results will be less than satisfactory (no antialiasing, distortion). So, we had to flip the quality up to StageQuality.HIGH and back every time we had to draw something into a bitmap.

That worked like magic. It was fast and reliable and allowed us to build application that uses the same assets for resolutions starting with older 480×320 devices to the flagships of industry 640×960 for iOS and 1280×720 for Android. However with 3.4 (actually 3.3) update to Adobe AIR it stopped working.

But not to worry! The new AIR, starting with 3.3 (that one is bugged though) is bringing the drawing method called drawWithQuality, which allows you to draw assets at a quality that is independent from the stage quality setting used in your app. So, instead of flipping quality back and forth for the entire stage, you just specify the desired level of quality in that method. It actually works even better than before because now we are using StageQuality.BEST for drawing (that particularly matters on Android devices). More on drawWithQuality here.

Example:

//create a source for drawing
var source = new Sprite();
source.graphics.beginFill(0xff6600);
source.graphics.drawRect(0,0, 200, 200);

//draw into bitmap
var bmp:BitmapData = new BitmapData(200, 200);
bmp.drawWithQuality(source, null, null, null, null, false, StageQuality.BEST);

One other thing you might want to consider doing…. If you are application is targeted to use GPU, it is recommended by Adobe that you update your application descriptor to use new “direct” as render mode instead of “gpu“, but this does not work well with Apple devices at the moment. Keep it as “gpu”.

There is a bunch of other new features and deprecations that came with the latest AIR SDKs, but the main thing it supports the new iOS 6 and it is easy to update your app to be iOS-safe!

PS Another great feature of  the AIR 3.4 runtime is a smaller footprint  of the .ipa file. Sketch Guess was reduced by 2.5Mb.

Support Us

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s