The Future of Flash part II – Flash in the AIR

In the previous blog post we discussed what the difference is between Flash and Flash player and hopefully made it clear that although the Flash Player is no longer supported on most of the handheld devices Flash, as a platform, is far from being dead. We also mentioned that Flash and Flash Builder are tools with which one can develop mobile applications. – How is that possible if the Flash Player, the application designed to play content authored in Flash is no longer available? – you might ask. The answer is the Adobe Integrated Runtime or AIR for short.

The Adobe Integrated Runtime can be downloaded separately for Android devices from the Play Market and can wrapped around the applications you create in Flash Pro if you are targeting an iOS device.
Ever since its 2.7 version it provides excellent playback and render quality for your apps on both Android and iOS but there are a few rules and best practices one needs to consider.

The most important is to go easy on the device’s CPU. Some of the handheld devices already have a GPU integrated but to keep everything nice and fluid on every supported device most of our graphics has to be changed from vector objects to pixel graphics. Luckily Flash Pro can generate a sprite sheet. Taking all used graphics and symbols into one neatly tagged .png file so instead of calculating the size and shape of vector graphics on runtime the app will simply fetch the images and stuff into the device memory. This lowers the load on the CPU so it will be faster, more responsive and less battery power will be drained while the app is running.
Watch Paul Trani’s video about creating sprite sheets in Flash:

While taking the load off from the device CPU also try to make sure that you are not dumping too much stiff into the memory so try avoiding large sprite sheets and other resources that take up too much memory. Pulling assets from a server might solve some of your problems but make sure that you optimize your network interactions as well and keep the key elements locally.
Adobe has released a whitepaper about optimizing performance for the Flash platform and it can be downloaded from here:

Use native extensions to expand user experience. Things like geo-location, vibration, tilt, speech recognition, in app purchase etc. can all be reached from an AIR application and you should make use of them! Read more about native extensions here:

Simplify your code as much as you can to avoid unnecessary calls and and enhance your AS3 performance. AS3 performance can be dramatically improved by using simple expressions like if, break and continue. You also want to use Display List, a tree like hierarchy of all Display Objects on screen. It helps you ensure that only those elements that only those elements get rendered that are needed. You can reed more about Display List here:

Finally you can make good use of something called Stage3D and StageVideo. Even if your app does not use 3D elements Stage3D will allow you to communicate with the devices GPU and make your content render faster. There are a number of frameworks that connect to Stage3D like Starling, the 2D framework behind Angry Birds. Read more about Stage3D and the awesome Frameworks and libraries here:

StageVideo will let you take advantage of hardware accelerated H.264 decoding and camera input to further enhance your app. Read more about the StageVideo Class here:
We encourage you to check out the showcase for games developed with flash and deployed via AIR or played in the flash player. You will find titles like Angry Birds, Teenage Mutant Ninja Turtles, Farmville 2 or Machinarium here: