21 September 2011
Adobe AIR has come a long way since version 1.0 was launched at the beginning of 2008. We've added dozens of major features, hundreds of minor features, performance improvements, and bug fixes, and we now support three additional platforms: iOS (iPhone and iPad), Android, and Adobe AIR for TV.
AIR 3 is our eleventh release in less than two and a half years. Although all of our major releases have represented big steps forward, I think this one is the most significant. AIR 3 includes the following new APIs and capabilities:
apk-captive-runtimeflag to ADT when building your Android app or the
bundleflag when building your desktop app. (Note that AIR has always used a captive runtime approach on iOS, although the mechanism is a bit different.)
CameraRollwas technically already supported on the iPad, we've added much better support in AIR 3. On iPads, the photo picker doesn't take up the entire screen, as it does on iPhones and iPod touches. Instead, it appears as a floating panel positioned relative to the UI component that invoked it. With the addition of the
CameraRollBrowseOptionsclass, developers can choose the size and position of the image picker, and specify the location of the UI component that invoked it. For more information and a code sample, see my blog post, How to correctly use the CameraRoll API on iPads.
StageVideo; now AIR 3 brings
StageVideoto mobile as well.
StageVideo(hardware-accelerated video) and
StageWebView(native HTML rendering). AIR 3 introduces the
StageTextAPI which allows developers to place native text fields in their mobile apps. Although you can still use Flash text fields, of course,
StageTexttext fields come with all the OS-specific perks like the magnifying glass, text selection, auto-correct, and so on.
CameraAPIs now have access to both front and rear-facing cameras on iOS and Android devices (for Android devices, verion 2.3 or later is required). You can use the new
Camera.positionproperty along with the constants in the new
UNKNOWN) to determine the location of the cameras. For more information and a code sample, see my blog post, Front-facing camera support in AIR 3.
EncryptedLocalStoreAPIs that are available on the desktop are now available on iOS and Android. This API is critical for securely storing user credentials, encryption keys, salts, and similar important information.
SoundMixer, and the constants in the new
VOICE), developers can control whether audio is played through the phone's earpiece or speakers.
ProgressEvent.SOCKET_DATA), and to determine how many bytes are available for reading (
Socket.bytesAvailable). However, the opposite hasn't been true. In other words, before AIR 3, there was no way to know that data had been successfully written from the ActionScript socket's write buffer to the network, and to know how many bytes were still waiting to be written. This led to situations where developers weren't sure if it was safe to call
close()on a socket, or to know if there was a network operation still in progress when the user wanted to shut down an application. Starting with AIR 3, developers can use the
OutputProgressEvent.OUTPUT_PROGRESSevent along with the new
Socket.bytesPendingproperty to determine how much data has been written to the network, and how much data is still in the ActionScript socket waiting to be written. These new APIs should lead to more robust applications that rely on network access through sockets. For more information and a code sample, see my blog post, Socket improvements in AIR 3.
Cameraclass in H.264.
Capabilities.hasMultiChannelAudioproperty, the new
AudioDecoderclass (containing constants representing several different multichannel audio types), and changes to the
Capabilities.serverStringproperty all allow developers to detect a device's multichannel audio capabilities and to stream the correct audio bitstream both from ActionScript and through RTMP.
GameInputAPIs, developers can build games that respond to advanced TV controllers. A number of new APIs allow for enumerating devices (available controllers), enumerating devices' controls (buttons, triggers, acceleration, etc.), and for getting control values from devices.
DisplayObjectContainernow has a
removeChildren()function, which removes all the children in a single call. This certainly beats:
while (this.numChildren > 0) this.removeChildAt(0)
MovieClipis playing using the new
System.pauseForGCIfCollectionImminentfunction gives AIR developers more control over when the runtime's automatic garbage collection reclaims memory. Since animation or audio may pause during garbage collection, developers can use this function to encourage collection at times when the user is least likely to notice.
Math.randomfunction, which returns "pseudo-random" numbers—that is, numbers which appear to be random but always contain some element of non-randomness (a timestamp, for instance). AIR 3 provides a new method for generating random numbers called
generateRandomBytes()located in the flash.crypto package. Since the
generateRandomBytes()function uses OS APIs to generate random numbers (
/dev/randomon OS X,
/dev/urandomon Android, and
SecRandomCopyByteson iOS), the resulting random number is as cryptographically secure as the underlying OS.
cubicCurveTo()function on the
Graphicsclass allows you to programmatically draw cubic Bézier curves natively without the use of third-party ActionScript code.
For more details on the changes in AIR 3, refer to the release notes.