We recently had the pleasure of attending the Adobe MAX 2010 conference in Los Angeles at the LA Convention Center. Adobe showed off some exciting new technologies that are either available to use today or in the coming future. What interested me the most was the latest Adobe AIR 2.5 platform for Windows, Macintosh, Linux, Android, iOS and Blackberry Tablet OS. This allows us to develop applications using the next version of the Flex framework to build mobile and desktop applications using a common code base.
So once we got back to the office after 25 hours of flying, I handed our developers an Adobe MAX 2010 Adobe Flash Platform DVD with all the preview software. We dived straight into mobile development with the latest Flash Builder “Burrito” and Flex SDK “Hero” framework.
The result of our efforts was an iTunes Trailers application on the AIR for Android platform.
One thing that we noticed was, if you are already familiar with Flex, then you do not have to learn anything new. There are a few new components implemented to support mobile devices such as MobileApplication, TabbedMobileApplication and ActionBar. Also, you can have something up and running pretty quickly compared to other mobile platforms.
When you first create your project instead of extending Application, it extends MobileApplication. This class does a lot of work for you, including orientation support, persistence manager to save and restore state, listeners for the hardware buttons and the ViewNavigator (see description below).
“The ViewNavigator component is a container that consists of a collection of View objects, where only the top most view is visible and active. Views can be added and removed by using the popView() and pushView() methods on the navigator. When a new view becomes active, the old view’s instance is destroyed. When a view is pushed on top of navigator’s stack, the old view’s data property is automatically persisted and restored when it is reactived through one of the pop methods. ViewNavigator doesn’t provide index information about the Views that it is currently managing and strictly follows a stack navigation model. Jumping between a set of views similar to a ViewStack is not supported by this component. ViewNavigator displays an optional action bar that displays contextual information defined by the active view. When the active view changes, the action bar is automatically updated.”
You cannot define any visual components in the MobileApplication class, you will notice that it contains a property called firstView, which is the initial view your application will start with. Each view on the navigation stack must extend View. It extends Group and adds additional properties to communicate with it’s parent navigators’ various UI controls.
MobileApplication provides a way to persist your application’s view state and data when the application quits, so that the next time it starts, it can restore itself with the same current view and view history. This makes interruptions in your application’s life-cycle completely transparent to the user. This is very important on mobile devices, where the operating system can interrupt or kill an application at any time.
The ActionBar class defines a component that includes title, navigation and action content groups. In the context of a ViewNavigator and MobileApplication , the ActionBar is used as application chrome which is has content contributed by the active View. The screen shot above contains a back button in the navigation content group with the default title. The iTunes Trailers app we developed is using the default chrome and colors. Developers can however implement there own skins using ActionScript, FXG or bitmaps (recommended approach by Adobe for optimisation) rather than MXML and runtime MXML graphics. A good place to start would be to look at the ButtonSkin class under the package spark.skins.mobile. This will give you a good idea of how to go about developing your own mobile skins.
The List and Scroller components have added functionality to enable touch-and-throw scrolling. To enable touch scrolling, set the new property called interactionMode style to touch. If you are using the mobile theme, then this style is automatically set on all appropriate components for you, so no need to do anything explicitly. You may however, develop a desktop application using AIR for touch screens, which would require you to set the property. The default item renderer for the List component on mobile devices is MobileItemRenderer. This is a simple item renderer with a single text component.
There is a more advanced item renderer optimised for mobile devices called MobileIconItemRenderer, it contains four optional parts:
The screen shot below is using all of these parts of the item renderer.
If you would like to create your own advanced item renderer then Adobe recommends that you create a new ActionScript item renderer that extends MobileIconItemRenderer. Most of the time you probably won’t need to create your own item renderers but on rare occasions you may need to extend the functionality.
In part 2 we will go into more detail on how we built the application and integrated the services using Flash Builder “Burrito”, the design view to layout the views and how to package up the application for distribution on the Android Marketplace. Additionally, we will provide the source code for the application too.
For more information on Flex SDK “Hero” framework, check out these links:

If you are a Flex developer or wanting to learn Flex, i highly recommend you look at Adobe’s video training course called Flex 4 beta in a Week.
The course is broken up over 5 days as follows:
Day 1 – Exploring the basic, Introducing object-orientated programming and Understanding components and layouts
Day 2 – Handling events, Validating and formatting data, Navigating application content and Animating components and states
Day 3 – Controlling text display, Controlling visual display and CSS and Skinning Spark components
Day 4 – Extending events, Accessing remote data and Creating a typed data model
Day 5 – Displaying data with the DataGroup container, Displaying Data with the DataGrid control and Deploying Flex and AIR Applications
Seasoned Flex developers may only find some of these areas useful, such as the Skinning Spark components and Displaying data with the DataGroup container (Coming soon).
At ThoughtFaqtory we are continually encouraged to think outside of the box when challenges are presented. A challenge was set recently by a pretty innocuous requirement from one of our clients.
This project required me to implement functionality that would allow the end user to export groups of images to PDF. The PDF needed to be high quality, 300 ppi (pixels per inch). After some searching I came across the AlivePDF website which appeared to be perfect for my requirements. Initially after using AlivePDF to generate a few PDFs, I couldn’t believe how easy it was to use and I thought that I had found Utopia. My joy however was short lived after the following error message was received:
AlivePDF had no alpha channel support for PNGs and the PNG encoder provided by Adobe always returns a PNG with an alpha channel. Even if you turned off the transparency you will get back a 32 bit ARGB PNG.
I continued searching for someone who had a method of successfully removing the alpha channel but my search proved fruitless. Hence I decided to do my own research into PNGs and found the following:
A valid PNG consists of:
PNG signature
IHDR chunk (only one)
IDAT chunk (one or more)
IEND chunk (only one)
The PNG signature:
89 50 4E 47 0D 0A 1A 0A.
The IHDR image header:
| Width: | 4 bytes |
| Height: | 4 bytes |
| Bit depth: | 1 byte |
| Colour type: | 1 byte |
| Compression method: | 1 byte |
| Filter method: | 1 byte |
| Interlace method: | 1 byte |
The IDAT chunks contain the image data.
The IEND chunk marks the end of the PNG.
The colour type under the IHDR chunk needs to be mentioned here as that is where the image type is defined.
| Image type | Colour type |
| Greyscale | 0 |
| True colour | 2 |
| Indexed colour | 3 |
| Grey scale with alpha | 4 |
| True colour with alpha | 6 |
After familiarizing myself with PNGs, I revisited Adobe’s PNGEncoder.as class again and eventually managed to make certain changes that allowed the removal of the alpha channel all together.
After all the research this ended up being a lot easier than I had originally thought, all that I needed to do was change the colour type and extract the RGB values. Adobe’s colour type was 6 (True colour with alpha) I changed it to 2 (True colour only). Next I needed to isolate and extract the RGB values, this was done with a bitwise right shift operation and a bitwise AND operation.
// Build IHDR chunk var IHDR:ByteArray = new ByteArray(); IHDR.writeInt(w); IHDR.writeInt(h); IHDR.writeUnsignedInt(0x08020000); // True colour (no alpha) IHDR.writeByte(0); writeChunk(png, 0x49484452, IHDR); // Isolate RGB values for (var j:int = 0; j < w; j++) { p = img.getPixel(j, i); IDAT.writeByte(p >> 16 & 0xFF); IDAT.writeByte(p >> 8 & 0xFF); IDAT.writeByte(p & 0xFF); }
The changes implemented resulted in the removal of the Alpha channel which allowed me to successfully embedded the encoded PNG image into a PDF with AlivePDF. This was the first of many problems I had working with PDFs, maybe you will get to read about the others in the not too distant future. Attached below is a sample application that will embed a PNG into a PDF.
[kml_flashembed publishmethod="static" fversion="10.0.0" movie="http://thoughtfaqtory.com/blog/wp-content/uploads/2009/10/pngalpha1.swf" width="630" height="400" targetclass="flashmovie" ]
[/kml_flashembed]
One of my colleagues at ThoughtFaqtory found this nice resource “Learn to Use Flash Catalyst” on Adobe Labs web site.
I have listed all the tutorials, videos and screencasts below.
Get Started
Learn about Flash Catalyst
Start Building Your First Flash Catalyst Application
Get Better
Explore Flash Catalyst Workflows
Work with Flash Catalyst
Learn from the Community