Flash Development for Android Cookbook
上QQ阅读APP看书,第一时间看更新

Using Flash Builder 4.5 to develop Android applications

Flash Builder 4.5 already comes equipped with everything, we need to begin developing mobile applications using either ActionScript or the mobile Flex Framework. For those unfamiliar with the differences between ActionScript and Flex, basically, the Flex framework provides a set of components, layouts, and data control that is preconfigured for building Flash applications, whereas when using ActionScript by itself, everything must be written from scratch. Flex 4.5 includes mobile features such as optimized component skins to run very well on devices, a new ViewNavigator application type, which is tailored to the mobile experience, and includes support for touch and gestures across the mobile-optimized component set.

How to do it…

In place of a normal ActionScript project or Flex project, we must specifically create either an ActionScript Mobile project or Flex Mobile project:

  1. In the Flash Builder Package Explorer, right-click on some empty space and choose New | Flex Mobile Project or New | ActionScript Mobile Project:
  2. We will then provide the mobile project with a name and choose where Flash Builder should store the project files on the local machine.
  3. The next step allows us to choose the target platform, in this case, Google Android, and define which application template to use (if you are making use of the mobile Flex framework). We can also set the default View name on this screen through the Initial view title input..
  4. Additionally, we will choose whether or not the application will reorient based upon device tilt with the Automatically reorient option. We can select to display the application at full screen by selecting the Full screen checkbox.
  5. One last selection to make on this screen is whether we would like to use density aware skins in our mobile components by selecting the Automatically scale application for different screen densities checkbox and selecting the appropriate Application DPI setting.
  6. The rest of the project setup is really the same as any other project in Flash Builder.

How it works…

The choices we make when setting up a new project in Flash Builder determine which libraries are imported, and used in an application. Defining a mobile application will not only include specific component skins targeted to mobile, but will also restrict us from using components, which are inappropriate for such use. We will also have full access to mobile-specific application structures such as the mobile ViewNavigator, ActionBar, or TabBar. These additions to the mobile Flex framework can be used to greatly speed up the development of stateful mobile Android applications, as they deal with application structure, navigation controls, and layout.

See also…

You can actually use previous versions of Flash Builder to compile AIR for Android applications. Check out the next recipe, Enabling Flash Builder 4 or Flex Builder to access Flex Mobile SDKs for an example of this.