Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Flash Development for Android Cookbook
Flash Development for Android Cookbook

Flash Development for Android Cookbook: Over 90 recipes to build exciting Android applications with Flash, Flex, and AIR

eBook
$28.99 $32.99
Paperback
$54.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with Print?

Product feature icon Instant access to your digital copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Redeem a companion digital copy on all Print orders
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Table of content icon View table of contents Preview book icon Preview Book

Flash Development for Android Cookbook

Chapter 1. Getting Ready to Work with Android: Development Environment and Project Setup

This chapter will cover the following recipes:

  • Using Flash Professional CS5.5 to develop Android applications

  • Targeting AIR for Android with Flash Professional CS5.5

  • Using Flash Builder 4.5 to develop Android applications

  • Enabling Flash Builder 4 or Flex Builder to access Flex Mobile SDKs

  • Using Flash Builder 4 and below to develop Android applications

  • Using Powerflasher FDT 4.2 to develop Android applications

  • Enabling Powerflasher FDT 4.1 to access Flex Mobile SDKs

  • Using Powerflasher FDT 4.1 and below to develop Android applications

  • Converting a Standard Flex project to a Flex Mobile project

  • Configuring the AIR SDK to Package AIR for Android applications on Windows

  • Configuring the AIR SDK to Package AIR for Android Applications on Linux or Mac OS

Introduction


There are many choices of IDE (Integrated Development Environment) for developing Flash platform projects for Android devices. We will focus on a few of the most popular: Adobe Flash Professional, Adobe Flash Builder, and Powerflasher FDT. This chapter will include recipes geared to getting a new Android project started in each IDE, and making the most of what is available with regard to workflow and toolsets. You will learn how to configure each environment in order to develop for the Android operating system.

Flash Builder and FDT, along with the Flex framework have the most to offer for Android development as there is a streamlined workflow, set of controls, and containers available especially for the development of mobile Android projects using Adobe AIR for Android as a development platform.

Flash Professional provides some workflow tools, but the main benefit lies in potential familiarity with the environment, and the generation of projects not tied to the Flex framework. This IDE is often used for game development because of its open nature.

For the purists or users of alternative IDEs, it is also possible to generate Android applications through a command line interface using the free AIR SDK tools.

Using Flash Professional CS5.5 to develop Android applications


Flash Professional is a good choice for building Android applications that are more lightweight than their Flex-based counterparts. There is not as robust a workflow in the case of Flash Professional when compared to what is included with an IDE such as Flash Builder, but depending upon the application being developed, it may be the better tool for the job.

Flash Professional CS5.5 includes everything needed to target Android already baked in!

How to do it…

Setting up an AIR for Android project in Flash Professional CS5.5 is very direct:

  1. 1. We will first create a new project by choosing AIR for Android under the Create New section of the Flash Professional welcome screen:

  2. 2. We can then verify that we are targeting AIR for Android by taking a look at the document properties under the Properties panel:

  3. 3. We can also modify existing Flash documents to target Android by selecting AIR for Android as the Player option.

  4. 4. Now, simply build your Flash project as you normally would. Adobe has made the process of targeting Android with Flash Professional CS5.5 absolutely painless.

How it works…

With Flash Professional CS5.5, we have more compiler options available to us than ever before. Taking the steps outlined in the preceding section will ensure that your project is capable of targeting AIR for Android in place of the desktop Flash Player or AIR for desktop by adding a number of Android-specific compiler options to our publish settings.

There's more…

If developing for the mobile Flash Player for Android, we will not need to configure anything for the AIR runtime. To target Flash Player, we must simply keep in mind the limitations and differences inherent to mobile Android devices.

Targeting AIR for Android with Flash Professional CS5.5


Flash Professional is a good choice for building Android applications that are more lightweight than their Flex-based counterparts. There is not as robust a workflow in the case of Flash Professional when compared to what is included with an IDE such as Flash Builder, but depending upon the application being developed; it may be the better tool for the job.

How to do it…

There are two ways of targeting AIR for Android with Flash Professional:

  1. 1. Firstly, create a new project by choosing AIR for Android under the Create from Template section of the Flash Professional welcome screen:

  2. 2. This will present a choice of several templates targeting AIR for Android. Choose the appropriate template for your device:

  3. 3. Alternatively, create a new ActionScript 3.0 project and open your publish settings by going to File | Publish Settings.

  4. 4. This will open a dialog allowing you to choose your target platform. In this case, we want to select AIR Android as the appropriate Player:

  5. 5. Now you will be able to adjust Application and Installer Settings targeting Android, and compile projects into .apk files.

How it works…

With recent versions of Flash Professional, we have more compiler options available to us than ever before. Taking the stepsoutlined abovewill ensure that your project is capable of targeting AIR for Android in place of the desktop Flash Player or AIR for desktop by adding a number of Android-specific compiler options to our publish settings.

There's more…

If developing for the mobile Flash Player for Android, we will not need to configure anything for the AIR runtime. To target Flash Player, we must simply keep in mind the limitations and differences inherent to mobile Android devices.

See also…

For more information about compiling AIR for Android applications with Flash Professional, you will want to refer to Chapter 11, Final Considerations: Application Compilation and Distribution

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. 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. 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. 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. 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. 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. 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.

Enabling Flash Builder 4 or Flex Builder to access Flex Mobile SDKs


You don't necessarily need to have the latest version of Flash Builder to write applications for Android. This recipe will demonstrate how to integrate the latest Flex SDK into an older version of Flash Builder (or even Flex Builder) to take advantage of the mobile framework improvements.

Note

Even though we will be able to use the new component sets and streamlined structure for Android, many of the workflow enhancements such as support for a new mobile application view structure, optimized component skins with touch and gesture support, and other niceties found in newer versions of Flash Builder simply will not exist and we will have to compile the application for distribution using the AIR SDK and command line tools.

How to do it…

The following steps are used for getting an older version of Flash Builder configured for Android development:

  1. 1. Visit the Adobe Open Source website at http://opensource.adobe.com/ and locate the latest build of the Flex SDK.

  2. 2. Download a ZIP file of the latest Adobe Flex SDK and extract it to a hard drive to a location you will remember. For instance, C:\SDKs\Flex.

  3. 3. Launch Flash Builder and go to Window | Preferences.

  4. 4. Scroll down the Flash Builder menu item and select Installed Flex SDKs. You will now see a list of each of the SDKs currently available in your copy of Flash Builder:

  5. 5. Click the button labeled Add… and browse to the location of the Flex SDK you recently downloaded.

  6. 6. Provide the dialog with a meaningful name and click OK. For example, Flex 4.5. If we want to be very specific, we can always name it the full build name, such as: Flex 4.5.0.16076.

  7. 7. The Flex 4.5 SDK will now be available for use in your application. To use it in a project, simply select this SDK when creating a new project or when modifying the Flex Compiler properties in an existing project.

How it works…

Using a more recent version of the Flex SDK within Flash Builder allows us access to the mobile theming options and other specific APIs not available in previous SDK releases. This will also expose mobile classes to code hinting and other IDE workflow constructs.

There's more…

If changing the Flex SDK version to be used in a project, we may receive a number of warnings or errors due to changes in the framework from version to version. Simply go through the project files and correct each warning or error that appears within the Problems panel to correct any issues.

If developing projects that target Flash Player on Android, you simply need to be mindful of device and operating system constraints.

See also…

It is important to note that versions of Flash Builder prior to Flash Builder 4.5 will not include the ability to compile projects to .APK (the Android application file extension) and you will need to compile your project using the freely available AIR SDK. See Chapter 11, for information on how to do this.

It is also worth a mention that while you can develop your applications for Android using older versions of Flash Builder, you will not receive many of the benefits provided by a newer release, such as code completion.

Using Flash Builder 4 and below to develop Android applications


To develop mobile Android application in Flash Builder 4, we will need to configure Flash Builder to enable access to a mobile Flex SDK. See the previous recipe if you have not yet configured Flash Builder or Flex Builder in this manner.

How to do it…

There is no specific mobile workflow or tooling built into versions of Flash Builder prior to Flash Builder 4.5. By taking the following steps, we can ensure that our project will be mobile-compatible:

  1. 1. In Flash Builder, right-click in the Package Explorer panel and choose New | Flex Project. Alternatively, we can choose ActionScript Project, but this will not include any mobile benefits, as the actual Flex SDK components will not be employed. However, it is useful to note that ActionScript projects will generally perform better than their Flex counterparts simply due to the fact that they do not rely on such a heavy framework.

  2. 2. The New Flex Project dialog will appear in which you must provide a Project name, and select whether to create the project targeting Web or Desktop. If this project will be compiled for AIR for Android, we will want to make sure to choose Desktop, as this application type will target the Adobe AIR runtime. If creating a project targeting Flash Player in the browser, we will choose Web.

  3. 3. When choosing Desktop, we will also want to be sure to choose a mobile-enhanced version of the Flex SDK for our Android project. Flex 4.5 and above include everything we need to begin developing robust Android applications.

  4. 4. The last thing we must do is make sure that the mobile-enabled Flex SWCs are going to be used in our project. In order to declare <s:ViewNavigatorApplication> or <s:TabbedViewNavigatorApplication> for the main container of our project, these specific SWCs must be accessible, else Flash Builder will report errors.

  5. 5. The final section of the New Flex Project dialog allows us to be sure the mobile SWCs are included. You will notice that mobilecomponents.swc is not included in our project. Select the tab labeled Library path and click on the button labeled Add SWC…:

  6. 6. When the Add SWC dialog appears, browse to the location of the selected Flex SDK. Assuming we unpackaged the SDK to C:\SDKs\Flex4 we will now browse to C:\SDKs\Flex\frameworks\libs\mobile select the mobilecomponents.swc file, and click on Open. This will add support for the mobile components to our application.

  7. 7. Complete the project setup. We are now able to use mobile specific containers and controls without receiving errors from Flash Builder, but we must make a few more adjustments in order to correctly compile our application.

  8. 8. Locate the AIR descriptor file in your project. It is normally named something like {MyProject}-app.xml and resides at the project root. Open this file and change the <visible> attribute to true. It may be necessary to uncomment this node, if it has been commented out.

  9. 9. Right-click on your project in the Package Explorer and select Properties.

  10. 10. Select the Flex Compiler menu option and add the following to the Additional compiler arguments: theme=C:\{SDK Location}\frameworks\themes\Mobile\mobile.swc

  11. 11. Finally, switch the root node of your main application file from <s:Application> to <s:ViewNavigatorApplication>. We can now author and compile applications using the mobile flex framework components.

How it works…

When specifying which type of project we want to create in Flash Builder, the IDE automatically makes available certain portions of the Flex framework so that we can work with all the components necessary for our project. Flash Builder 4 and earlier do not ship with any mobile-enabled Flex SDK and do not provide a workflow for Android projects. Because of this, we must explicitly tell Flash Builder to make use of these extra framework components.

The application descriptor file mentioned in the steps in the preceding section is used to configure an AIR application in various ways: setting the initial window properties, chrome attributes, and even system icons.

See also…

It is important to note that versions of Flash Builder prior to Flash Builder 4.5 will not include the ability to compile projects to .APK (the Android application file extension) and you will need to compile your project using the freely available AIR SDK. See Chapter 11 for information on how to do this.

It is also worth a mention that while you can develop your applications for Android using older versions of Flash Builder, you will not receive many of the benefits provided by a newer release, such as code completion.

Enabling Powerflasher FDT 4.1 to access Flex Mobile SDKs


Powerflasher FDT is an increasingly popular development environment for authoring projects for the Flash Platform. FDT 4 comes equipped with everything you'd expect to begin developing ActionScript and Flex applications, but FDT 4.1 and below do not support any mobile workflow or ship with the mobile-enabled Flex SDK.

How to do it…

There are only a few steps to getting Powerflasher FDT 4 configured for Android development:

  1. 1. Visit the Adobe Open Source website at http://opensource.adobe.com/ and locate the latest build of the Flex SDK.

  2. 2. Download a ZIP file of the latest Adobe Flex SDK and extract it to a hard drive to a location you will remember. For instance, C:\SDKs\Flex.

  3. 3. Launch FDT and go to Window | Preferences.

  4. 4. Scroll down the FDT menu item and select Installed SDKs. You will now see a list of each of the SDKs currently available in your copy of FD:

  5. 5. Click on the button labeled Add and browse to the location of the Flex SDK you recently downloaded.

  6. 6. Provide the dialog with a meaningful name and click OK. For example, Flex 4.5:

  7. 7. The Flex 4.5 SDK will now be available for use in your application. To use it in a project, simply select this SDK when creating a new project or when modifying the Flex Compiler properties in an existing project:

How it works…

Powerflasher FDT 4 is an Eclipse-based IDE (just like Flash Builder) and employs many of the same methods of extending the application and adding SDK packages. Using a more recent version of the Flex SDK within FDT allows us access to the mobile theming options and other specific APIs not available in previous SDK releases.

See also…

It is important to note that versions of Flash Builder prior to Flash Builder 4.5 will not include the ability to compile projects to .APK (the Android application file extension) and you will need to compile your project using the freely available AIR SDK. See Chapter 11 for information on how to do this.

It is also worth a mention that while you can develop your applications for Android using older versions of Flash Builder, you will not receive many of the benefits provided by a newer release, such as code completion.

Using Powerflasher FDT 4.1 and below to develop Android applications


To develop mobile Android application in FDT 4.1, we will need to configure FDT to enable access to a mobile Flex SDK. See the previous recipe if you have not yet configured FDT in this manner.

How to do it…

There is no specific mobile workflow or tooling built into versions of FDT prior to FDT 4.2. By taking the following steps, we can ensure that our project will be mobile-compatible:

  1. 1. In FDT, right-click in the Flash Explorer panel and choose NEW | New Flash Project:

  2. 2. The New Flash Project dialog will appear in which you must provide a Project name, and select whether to create the project using ActionScript 3 or Flex. We need to make sure to choose Flex 4, as this will include Spark components, which can be mobile-friendly if using a proper version of the Flex SDK.

  3. 3. The next section will allow us to choose a specific Flex SDK to use in our project. We should choose a mobile-enhanced version of the Flex SDK for our Android project. Flex 4.5 and above include everything we need to begin developing robust Android applications.

  4. 4. The last thing we must do is make sure that the mobile-enabled Flex SWCs are going to be used in our project. In order to declare <s:ViewNavigatorApplication> or <s:TabbedViewNavigatorApplication> for the main container of our project, these specific SWCs must be accessible, else FDT will report errors.

  5. 5. The next section allows us to be sure the mobile SWCs are included. Select the tab labeled SDK Library and click on the button labeled Select SWCs…

  6. 6. You will notice that mobile\mobilecomponents.swc is not included in our project. Select the checkbox next to this SWC and press the OK button to continue:

  7. 7. Now we will be able to use mobile specific containers and controls without receiving errors from FDT.

How it works…

When specifying which type of project we want to create in FDT, the program automatically makes available certain portions of the Flex Framework, so that we can work with all the components necessary for our project. FDT 4.1 and earlier do not ship with any mobile-enabled Flex SDK and do not provide a workflow for Android projects. Because of this, we must explicitly tell FDT to make use of the following extra framework components:

  • ViewNavigatorApplication: This includes a ViewNavigator stack structure, in which we can push and pop different views to the top of a stack, exposing the topmost view to the user.

  • TabbedViewNavigatorApplication: This includes the ability to have multiple ViewNavigator stacks within an application, controlled through a TabBar user interface element.

See also…

It is important to note that versions of Flash Builder prior to Flash Builder 4.5 will not include the ability to compile projects to .APK (the Android application file extension) and you will need to compile your project using the freely available AIR SDK. See Chapter 11 for information on how to do this.

It is also worth a mention that while you can develop your applications for Android using older versions of Flash Builder, you will not receive many of the benefits provided by a newer release, such as code completion.

Converting a standard Flex project to a Flex Mobile project


There is currently no workflow within Flash Builder (or FDT) to convert an existing application to a mobile Android application. Depending upon the complexity of the application being converted and the version of Flex, it may be undergoing conversion from this task can range from the very simple to one that is inordinately complex. In this recipe, we will demonstrate a simpler example using basic Flex structures.

How to do it…

Create a new mobile project and copy all of the necessary files into it, retaining those portions of code which are used for mobile projects and modifying any unsupported components.

For this example, we'll use a simple Flex project targeting AIR for desktop consisting of nothing but a button component at this stage:

<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx">
<s:Button x="10" y="10" width="300" height="200" label="Button"/>
</s:WindowedApplication>

To convert this to a new Flex Mobile project, take the following steps:

  1. 1. Go to the menu and choose File | New | Flex Mobile Project.

  2. 2. Provide the project setup dialog with information about the new mobile project.

    Note

    The project cannot have the same name as any existing project within your environment.

  3. 3. Copy all of your files from the project folder in your original project into this new mobile project excluding your project descriptor file ({myApp }.xml) and Default Application files.

  4. 4. Now, copy everything within your old Default Application file and paste it into the Default Application file that was created along with your mobile project. Once everything has been copied over, right-click on the main application file and choose Set as Default Application.

  5. 5. Change all instances of <s:WindowedApplication> to <s:ViewNavigatorApplication> (alternatively, <s:TabbedViewNavigatorApplication>).

    Note

    Just as with a standard AIR <s:WindowedApplication>, only one instance of <s:ViewNavigatorApplication> or <s:TabbedViewNavigatorApplication> can exist within a project.

  6. 6. Look within your Problems panel to see whether or not any further modifications need to be made.

  7. 7. If you are not using any of the old Halo components (mx namespace) it is a good idea to remove the namespace declaration for your opening <s:ViewNavigatorApplication> tag.

  8. 8. Add a firstView attribute to the <s:ViewNavigatorApplication> tag. This should point to the View automatically created when you set up the mobile project.

  9. 9. Since visual UI elements cannot reside directly within a <s:ViewNavigatorApplication /> node, we must wrap the <s:Button /> instance within a <fx:Declarations> </fx:Declarations> tag set, or move it to a specific View.

Note

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

Your Default Application file should now read as follows:

<?xml version="1.0" encoding="utf-8"?>
<s:ViewNavigatorApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark" firstView="views.MobileFlexProjectHomeView">
<fx:Declarations>
<s:Button x="10" y="10" width="447" height="106" label="Button"/>
</fx:Declarations>
</s:ViewNavigatorApplication>

Additionally, a view for this application could appear as such:

<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark" title="MobileFlexProjectHomeView ">
</s:View>

For more information about how Flex Mobile projects are structured, have a look at the following resource: http://opensource.adobe.com/wiki/display/flexsdk/Developer+Documentation.

How it works…

When using Flex, the root tag of your application determines largely what APIs and structures are available to you throughout the project. Making sure that we choose the correct root tag is very important in regard to the target platform and capabilities of our project. For AIR on Android, we will want to use either ViewNavigatorApplication or TabbedViewNavigatorApplication. Desktop applications would use the Application or WindowedApplication tags. Chances are, if you are building Flash content with Flex that is to be deployed to Flash Player in the browser, on both mobile and desktop you will use a straight Application tag for your project.

There's more…

If you don't want to deal with a lot of conversion, and are just starting out with a new project that will share the same codebase across desktop and mobile, you might consider using a Flex Library project to allow different projects to share the same underlying codebase.

Read the documentation on Flex 4 Library usage at: http://help.adobe.com/en_US/flashbuilder/using/WS6f97d7caa66ef6eb1e63e3d11b6c4d0d21-7fe6.html.

Configuring the AIR SDK to package AIR for Android applications on Windows


If we are using the open source AIR SDK (Software Development Kit) with another IDE or even editing our project in a simple text editor, we can still compile applications for distribution on Android through command line tools.

How to do it…

If you do not already have the Adobe AIR SDK, you must first download it from http://www.adobe.com/products/air/sdk/ and extract the files into a directory on your hard drive, C:\SDKs\AIR, for example. You must also set a PATH variable in your operating system pointing to the bin directory underneath the AIR SDK.

If you are using a Windows system, set the environment variable through the following steps:

  1. 1. Open the System Properties dialog. You can reach this dialog in many ways, the most direct being a right-click on My Computer. Then select Properties.

  2. 2. Choose Advanced system settings from the left hand menu.

  3. 3. Click on the button at the bottom of this window that says Environment Variables…

  4. 4. Click upon the PATH variable in this window and select Edit:

  5. 5. Now, simply add the location of your bin directory into the set of variables: If the last item in your variable value list has not been terminated with a semicolon, you must add one before every new item. For example: C:\SDKs\AIR\bin.

  6. 6. That should do it. Hit OK a few times and bring up the command prompt to verify that we've set this up correctly. Type in adt -version and hit Enter. If all is well, ADT will spit back a version string that looks something like adt version "2.5.0.00000".

How it works…

Setting a PATH variable on the operating system allows us to be able to invoke the AIR Android compiler, ADT, from anywhere in our system without having to traverse file directories and specify long path names.

See also…

If using a Linux or Mac operating system, you can also set specific environment variables from within the Terminal. See the next recipe Configuring the AIR SDK to Package AIR for Android Applications on Linux or MacOS for an example of this.

Configuring the AIR SDK to package AIR for Android applications on Linux or Mac OS


If we are using the open source AIR SDK with another IDE or even editing our project in a simple text editor, we can still compile applications for distribution on Android through command line tools.

How to do it…

If you do not already have the Adobe AIR SDK, you must first download it from http://www.adobe.com/products/air/sdk/ and extract the files into a directory on your hard drive: /home/joseph/SDKs/AIR, for example. You must also set a PATH variable in your operating system start up script pointing to the bin directory underneath the AIR SDK.

We will set the environment variable through the following steps:

  1. 1. Open the Terminal.

  2. 2. Now we must create the shell configuration profile. Enter the following into the Terminal window: cat >> .bash_profile on a Mac or cat >> .bashrc for Ubuntu (each Linux distribution may have its own particular naming convention for the startup script).

  3. 3. Next, enter export PATH=$PATH:/home/joseph/SDKs/AIR/bin to set the PATH variable pointing to the AIR development tools bin directory. Hit Enter.

  4. 4. Enter Ctrl+Shift+D to end this process.

  5. 5. Now we will check to be sure everything was added appropriately. Type cat .bashrc into the Terminal and hit Enter. You should see the PATH command spit back at you:

  6. 6. You may need to log out of your profile and then log back in for the new environment variable to be picked up by the system.

  7. 7. Bring up the Terminal again, after logging back into your profile.

  8. 8. Type echo $PATH into the Terminal and hit Enter. This should display everything that is included in the PATH variable including the location of our AIR bin directory.

  9. 9. That should do it. We will now verify that we've set the AIR SDK up correctly. Type in adt -version and hit Enter. If all is well, ADT will spit back a version string that looks something like adt version "2.5.0.00000":

How it works…

Setting a PATH variable on the operating system allows us to be able to invoke the AIR Android compiler, ADT, from anywhere in our system without having to traverse file directories and specify long path names.

See also…

Note that you may have to log out of your session and then log back in for the new PATH variables to take effect. If using a Windows operating system, you can also set specific environment variables. See the previous recipe, Configuring the AIR SDK to package AIR for Android applications on Windows for an example of this.

Left arrow icon Right arrow icon

Key benefits

  • The quickest way to solve your problems with building Flash applications for Android
  • Contains a variety of recipes to demonstrate mobile Android concepts and provide a solid foundation for your ideas to grow
  • Learn from a practical set of examples how to take advantage of multitouch, geolocation, the accelerometer, and more
  • Optimize and configure your application for worldwide distribution through the Android Market
  • Part of Packt's Cookbook series: Each recipe is a carefully organized sequence of instructions to complete the task as efficiently as possible

Description

Flash has now arrived to Android — the fastest growing smartphone platform. This offers massive opportunities for Flash developers who want to get into mobile development. At the same time, working on smartphones will introduce new challenges and issues that Flash developers may not be familiar with. The Flash Development for Android Cookbook enables Flash developers to branch out into Android mobile applications through a set of essential, easily demonstrable recipes. It takes you through the entire development workflow: from setting up a local development environment, to developing and testing your application, to compiling for distribution to the ever-growing Android Market. The Flash Development for Android Cookbook starts off with recipes that cover development environment configuration as well as mobile project creation and conversion. It then moves on to exciting topics such as the use of touch and gestures, responding to device movement in 3D space, working with multimedia, and handling application layout. Essential tasks such as tapping into native processes and manipulating the file system are also covered. We then move on to some cool advanced stuff such as Android-specific device permissions, application debugging and optimization techniques, and the packaging and distribution options available on the mobile Android platform. In a nutshell, this cookbook enables you to get quickly up to speed with mobile Android development using the Flash Platform in ways that are meaningful and immediately applicable to the rapidly growing area of mobile application development.

Who is this book for?

This book contains recipes covering a variety of topics from the very simple to those that are more advanced. If you are a seasoned Flash developer, this book will get you quickly up to speed with what is possible with Android. For those who are new to Flash, welcome to the world of visually rich, rapid application development for mobile Android devices! If you have any interest in Flash development for Android, this book is for you.

What you will learn

  • Configure Flash Professional, Flash Builder, or FDT to develop Android applications cross-platform regardless of operating system
  • Convert Flex and ActionScript projects to true mobile experiences
  • Work with multitouch and gestures for a truly innovative user experience
  • Use the geolocation and accelerometer sensors to respond to location and movement
  • Make use of the built-in microphone and camera hardware for user generated content
  • Stream audio and video to an application using a variety of protocols
  • Use advanced image display and modifications using custom shaders
  • Effectively scale and position the interface elements across devices
  • Employ a variety of URI handlers to invoke native SMS, telephone, e-mail, maps, and more
  • Work with the Android file system and manage application databases easily
  • Compile and submit your application or game to the ever growing, worldwide Android Market
Estimated delivery fee Deliver to United States

Economy delivery 10 - 13 business days

Free $6.95

Premium delivery 6 - 9 business days

$21.95
(Includes tracking information)

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Jun 16, 2011
Length: 372 pages
Edition : 1st
Language : English
ISBN-13 : 9781849691420
Category :
Languages :

What do you get with Print?

Product feature icon Instant access to your digital copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Redeem a companion digital copy on all Print orders
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Estimated delivery fee Deliver to United States

Economy delivery 10 - 13 business days

Free $6.95

Premium delivery 6 - 9 business days

$21.95
(Includes tracking information)

Product Details

Publication date : Jun 16, 2011
Length: 372 pages
Edition : 1st
Language : English
ISBN-13 : 9781849691420
Category :
Languages :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total $ 164.97
Flash Multiplayer Virtual Worlds
$54.99
Flash iOS Apps Cookbook
$54.99
Flash Development for Android Cookbook
$54.99
Total $ 164.97 Stars icon

Table of Contents

11 Chapters
Getting Ready to Work with Android: Development Environment and Project Setup Chevron down icon Chevron up icon
Interaction Experience: Multitouch, Gestures, and Other Input Chevron down icon Chevron up icon
Movement through Space: Accelerometer and Geolocation Sensors Chevron down icon Chevron up icon
Visual and Audio Input: Camera and Microphone Access Chevron down icon Chevron up icon
Rich Media Presentation: Working with Images, Video, and Audio Chevron down icon Chevron up icon
Structural Adaptation: Handling Device Layout and Scaling Chevron down icon Chevron up icon
Native Interaction: StageWebView and URI Handlers Chevron down icon Chevron up icon
Abundant Access: File System and Local Database Chevron down icon Chevron up icon
Manifest Assurance: Security and Android Permissions Chevron down icon Chevron up icon
Avoiding Problems: Debugging and Resource Considerations Chevron down icon Chevron up icon
Final Considerations: Application Compilation and Distribution Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.7
(13 Ratings)
5 star 69.2%
4 star 30.8%
3 star 0%
2 star 0%
1 star 0%
Filter icon Filter
Top Reviews

Filter reviews by




Mrs. Harsha Mehta Apr 10, 2018
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Happy with product. Very interesting
Amazon Verified review Amazon
Brian Mcclain Aug 31, 2011
Full star icon Full star icon Full star icon Full star icon Full star icon 5
All those Flash and Flex developers who are concerned about being sidelined by the mobile revolution need fret no longer. What they need to do is get a copy of the indispensible resource, Flash Development for Android Cookbook, by Joseph Lebracqu. As the title suggests, the book walks the reader through easy-to-follow exercises, each targeting a different , core aspect of mobile development. For example, chapter 2 is all about Actionscript Classses specific to the mobile experience, where there is no mouse. And so, we have Multitouch and Gesture Events. By Chapter 5, you are already ramped up to using audio and video, and tapping into the media stored on the Android device. And of course, tapping into the debice's GPS capabilities for creating uniquely mobile apps is also covered. Best of al -- and this cannot be emphasized enough -- the resulting apps are not simply running in the Flash player. The cookbook shows how to use the Air SDK running in conjunction with either Flash SC5.5 or Flash Develop 4.5 to compile your apps into native Android file format. The result are real Android apps--not just Flash Player running on an Android device. The only caveat here is that the reader must be at least intermediate level in Flash Actionscript 3. Knowledge of AS 3, and its events, functions and data-typing are assumed. That said, the material is logically presented and clearly explained, making it as easy as possible to follow this inherently advanced material. The reader will benefit greatly from owning a copy of Flash Pro CS5.5, and/or Flash Develop 4.5 (although it is possible to develop without these). Naturally, a current Android enabled device to test ones apps is also a must, preferably both a tablet and a phone. The serious-minded developer will also have to put the time in, but these are very worthwhile investments -- so roll up your sleeves and get ready to dive in to the world of Flash Development for Android.
Amazon Verified review Amazon
DannyPG Sep 27, 2011
Full star icon Full star icon Full star icon Full star icon Full star icon 5
So, lately I've found myself trying to better myself in the world of flash programming. And I've come to the realisation that one of the best outlets for my creativity is on the mobile platform. Namely, the diverse Android mobile OS. However upon approaching this hefty task of writing an app for the Android, I found myself way out of my depth.You see, to program an app for Android you have to think about 101 more factors than you do with a normal PC app. Well only if you want the app to be any good that is...However fortunately for me, I just so happened to be presented with a marvellous new book specifically catered for my needs. The name of said brilliant book; "Flash Development for Android Cookbook".This book perfectly covers all the angles that an existing developer needs to progress on to Android development. Well, I say an "existing developer", but in actual fact you can pretty much pick up this book with very little prior knowledge in programming and still get your head around what is going on in a very short space of time.Right from the word go, the book is teaching you at a very rapid but very structured pace, all the things you should know. It even covers the basics such as setting up your projects to begin with. Which can be useful even for those veteran developers who just need their technique refreshed.Within days you will find yourself taking advantage of the Android's Multitouch, Gestures and other Inputs, and before you know it you have completed your app. Having utilised things like the systems accelerometer and visual and audio input, you will be shocked at how fast you have learned.All in all, I think that this book does a brilliant job at encouraging the learner and motivating them to keep progressing at a fast pace, no matter what level of programming they begun with. Definitely a title to check out if you are interested in breaking into the massive mobile app market. 9.5/10.If you want to find out more about the book, or get the digital version you can find more information at [...]
Amazon Verified review Amazon
C. Moeller Sep 29, 2011
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This book provides you with everything you need to start developing programs and games on android using Adobe AIR, assuming you already have some knowledge in ActionScript.It shows short "recipes" on how to interface with everything that you would want to on the phone, from gestures, drawing, acceleration and geolocation, camera, microphone, images, video, audio, local storage and SQLLite, to even putting the final app on the market.Every recipe is well written, and specific to the interface you will be looking for, so you can easily find how to use the accelerometer, or load up the browser within your app. Most examples show how to do everything in Flash Builder (Flex), Flash `professional', FDT, and even command line, so you have many options (although the code will work well in any of them).The only negative I found with the book is that in Chapter 1, you learn how to compile, and run a program on Android, but Chapter 10 is when it actually goes into debugging, and setting up different configurations for testing your app. I wasn't sure how to have the app test run in Windows instead of running on my Android directly until that chapter (although it is a cookbook- you pick which chapter is relevant what you're trying to do).If you have built applications or games using Flash/Flex before, and would like to have a version running on Android, this book will give you all the information you need, and is a great reference as well!Get it now to get your Flash apps running on Android!
Amazon Verified review Amazon
Christopher Griffith Oct 07, 2011
Full star icon Full star icon Full star icon Full star icon Full star icon 5
The world of mobile development is a new and exciting world for many Flash and Flex programmers. They are learning about a whole new development platform, that utilizes a variety of technologies like accelerometers, GPS, cameras, microphones, and touch screens, just to name a few. Joseph Labrecque, employed by the University of Denver as senior interactive software engineer specializing in the Adobe Flash Platform, has written a clear and concise collection of recipes on these and other mobile development specific topics.This book is not an introduction to development on the Flash Platform. Some familiarity with ActionScript is required. Nor is this book designed to have you work through an entire project from cover to cover (like the Classroom in the Book series). It is intended more as a reference guide.For example, the chapter on using geolocation will walk you through the various class imports that are required, as well as the methods and functions that can be accessed, but it does not place it within context of an actual application. The advantage is the reader can see just the relevant code for using geolocation in their application, without have to create a 'real-world' demo, which often confuses the reader in the end.Joseph does an excellent job in showing each topic for a variety of development environments. If you develop in Flash Professional, Flash Builder, or FDT, you will find this book useful."Flash Development fo rAndroid Cookbook" is one of my top recommended resources to anyone starting to develop in the mobile space.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is the digital copy I get with my Print order? Chevron down icon Chevron up icon

When you buy any Print edition of our Books, you can redeem (for free) the eBook edition of the Print Book you’ve purchased. This gives you instant access to your book when you make an order via PDF, EPUB or our online Reader experience.

What is the delivery time and cost of print book? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge? Chevron down icon Chevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order? Chevron down icon Chevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries: www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges? Chevron down icon Chevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live in Mexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live in Turkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order? Chevron down icon Chevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact customercare@packt.com with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at customercare@packt.com using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy? Chevron down icon Chevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on customercare@packt.com with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on customercare@packt.com within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on customercare@packt.com who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should receive the refund within 10 to 12 working days.
  5. If you are only requesting a refund of one book from a multiple order, then we will refund you the appropriate single item.
  6. Where the items were shipped under a free shipping offer, there will be no shipping costs to refund.

On the off chance your printed book arrives damaged, with book material defect, contact our Customer Relation Team on customercare@packt.com within 14 days of receipt of the book with appropriate evidence of damage and we will work with you to secure a replacement copy, if necessary. Please note that each printed book you order from us is individually made by Packt's professional book-printing partner which is on a print-on-demand basis.

What tax is charged? Chevron down icon Chevron up icon

Currently, no tax is charged on the purchase of any print book (subject to change based on the laws and regulations). A localized VAT fee is charged only to our European and UK customers on eBooks, Video and subscriptions that they buy. GST is charged to Indian customers for eBooks and video purchases.

What payment methods can I use? Chevron down icon Chevron up icon

You can pay with the following card types:

  1. Visa Debit
  2. Visa Credit
  3. MasterCard
  4. PayPal
What is the delivery time and cost of print books? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela