Book Image

Flash iOS Apps Cookbook

By : Christopher Caleb
Book Image

Flash iOS Apps Cookbook

By: Christopher Caleb

Overview of this book

The latest version of Flash Professional can directly target iOS, allowing Flash developers to write applications that will run natively on Apple's iPhone, iPad, and iPod touch. What's more, with Apple loosening its restrictions on third-party technologies, apps written in Flash can now be sold and distributed within the App Store.Flash iOS Apps Cookbook provides the recipes required to build native iOS apps using your existing knowledge of the Flash platform. Whether you want to create something new or simply convert an existing Flash project, the relevant steps and techniques will be covered, helping you achieve your goal.Learn how to configure and use Flash Professional for iOS development by writing and deploying a simple app to a device. Implement many iOS-specific features such a multi-touch, the virtual keyboard, camera support, screen orientation and the Retina display. Overcome the limitations of mobile development by mastering hardware acceleration and optimization. Whether you're an enthusiast or professional developer, the Flash iOS Apps Cookbook is your toolkit to creating high-quality content for iPhone, iPad and iPod touch.
Table of Contents (21 chapters)
Flash iOS Apps Cookbook
Credits
About the Author
Acknowledgement
About the Reviewers
www.PacktPub.com
Preface
Index

Preface

The iPhone is revolutionary. Every day, it seems, someone finds an innovative use for it and, in the App Store, the perfect outlet for their work. Its success has made apps cool and helped shift delivery of content away from the browser. Adobe has reacted to this change by repositioning the Flash platform, and providing the tools required for the creation and publication of native iOS applications directly from Flash Professional.

The Flash iOS Apps Cookbook is a culmination of my experience working with AIR for iOS since its beginnings. I have paid particular attention to the fundamentals, focusing on the groundwork that many newcomers find daunting. For those with a firm grasp of the basics, there is plenty to learn, from working with the device's many sensors, to maximizing the performance of graphics using hardware acceleration.

By the end of this book, you will have acquired the necessary skills to write and distribute your own native iOS applications using Flash. I hope that you will use what you have learned here to create beautiful applications that befit the talented and inspiring community you are about to become a part of.

What this book covers

Chapter 1, Getting Started with iOS App Development, leads you through the often intimidating process of becoming a registered iOS developer. By the end of the chapter you will have the necessary files required to publish native iOS apps from Flash Professional.

Chapter 2, Building iOS Apps Using Flash, covers everything required to configure Flash Professional and publish native iOS apps from it. You will also learn how to install apps on an iPhone for testing.

Chapter 3, Writing your First App, takes you through the steps necessary to build and test your very first iOS app using Flash Professional with a modest amount of ActionScript. Some best practices for development will also be explored.

Chapter 4, Porting Flash Projects to iOS, will get you started on the right foot when converting Flash projects from the desktop to iOS. You will learn how to work within mobile constraints and how to avoid common pitfalls that can often cripple an app's performance.

Chapter 5, Multi-touch and Gesture Support, will show you how to take full advantage of the touch-screen. You will learn how to detect multiple touch points and respond to swipe, pan, and pinch gestures with ActionScript.

Chapter 6, Graphics and Hardware Acceleration, provides invaluable recipes for an area that often causes frustration. We will cover powerful techniques for dramatically boosting your application's frame rate and learn the intricacies of Flash's rendering pipeline. With this knowledge, you will be able to push the graphics performance of your own creations to the limit!

Chapter 7, Working with Text and the Virtual Keyboard, will help you adjust to life without physical keys by exploring support for iOS's virtual keyboard and native text-input controls. Time will also be spent covering relevant features of Flash's own text engine.

Chapter 8, Screen Resolution and Orientation Changes, details how to render content on any iOS device regardless of its screen resolution or physical orientation. Support for the high resolution Retina display can also be found, along with instructions detailing how to set up a universal app that can target iPhone, iPad, and iPod touch.

Chapter 9, Geolocation and Accelerometer APIs, covers recipes that utilize both the device's GPS sensor and its accelerometer. Learn how to make location-aware apps, respond to changes in physical orientation and detect vibration.

Chapter 10, Camera and Microphone Support, will help you master two of the most popular sensors built into iOS devices. With the camera, you will learn how to shoot video, capture photos, and access the image library. This chapter will conclude by covering how to record and play back audio captured with the microphone.

Chapter 11, Rendering Web Pages, focuses on the presentation of web content—both directly within your app and by launching Safari. It also covers how to dynamically generate HTML, navigate the browsing history, and capture a snapshot of the current page.

Chapter 12, Working with Video and Audio, explores the many A/V options available when targeting iOS. In addition to utilizing Flash's popular FLV video format, this chapter will detail how to take advantage of hardware-accelerated H.264 video for best quality high-definition playback.

Chapter 13, Connectivity, Persistence, and URI Schemes, ties up some loose ends, beginning with Internet connectivity. Next, file system access is discussed—a topic touched upon by a number of recipes throughout the book. At the end of the chapter, space is given over to the use of URI schemes to launch various system apps including Mail, YouTube, App Store, and Maps.

Chapter 14, Using Native Extensions and ADT, details how to use the command line to take advantage of AIR for iOS features that aren't currently provided from Flash Professional directly. Specifically, you will learn how to use native extensions to access iOS-specific APIs missing from the AIR SDK. This chapter is not present in the book but is available as a free download at the following link: http://www.packtpub.com/sites/default/files/downloads/1383_Chapter14.pdf

Chapter 15, ActionScript Optimization, covers a range of invaluable optimizations that can be applied to your project's ActionScript. You will see how even the simplest of changes can improve your application's execution speed or improve its memory usage. This chapter is not present in the book but is available as a free download at the following link: http://www.packtpub.com/sites/default/files/downloads/1383_Chapter15.pdf

Appendix A, Flash Professional CS5.5 Specific Recipes, contains a list of the recipes throughout this book that require Flash Professional CS5.5 and AIR 2.6 or above. The appendix is not present in the book but is available as a free download at the following link: http://www.packtpub.com/sites/default/files/downloads/1383_AppendixA.pdf

Appendix B, ActionScript Optimization Measurements, provides the results from various optimizations detailed in Chapter 15. This appendix is not present in the book but is available as a free download at the following link: http://www.packtpub.com/sites/default/files/downloads/1383_AppendixB.pdf

What you need for this book

This book has been written for users of Adobe Flash Professional CS5 or CS5.5.

The majority of recipes covered are compatible with both CS5 and CS5.5. However, some are specific to CS5.5 and require the latest version of the Adobe AIR SDK.

You will also need an iPhone, iPad, or iPod touch. Flash Professional CS5.5 supports the development of applications for iOS 4 or above, whereas CS5 also provides support for older devices running iOS 3.

You can build native iOS apps using either Flash Professional for Mac OS X or Microsoft Windows.

Who this book is for

The material throughout this book is written for both beginners and seasoned developers with a working knowledge of ActionScript 3.0 and Flash Professional. If you ever want to leverage your existing Flash skills to write iOS apps, then this book will show you how, starting with the basics. Those users who are already up to speed can go directly to the more advanced topics that are on offer.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

The development of iOS apps using Flash Professional is commonly referred to as AIR for iOS. However, Flash Professional CS5 uses the term iPhone OS. This book will almost exclusively use the term AIR for iOS throughout.

Code words in text are shown as follows: "Keep the default location set to C:\OpenSSL-Win32."

A block of code is set as follows:

public function Main() {
  application = NativeApplication.nativeApplication;
  application.systemIdleMode = SystemIdleMode.KEEP_AWAKE;
  application.addEventListener(Event.ACTIVATE, activate);
  application.addEventListener(Event.DEACTIVATE, deactivate);
}

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

public function Main() {
  application = NativeApplication.nativeApplication;
  application.systemIdleMode = SystemIdleMode.KEEP_AWAKE;
  application.addEventListener(Event.ACTIVATE, activate);
  application.addEventListener(Event.DEACTIVATE, deactivate);
}

Any command-line input or output is written as follows:

openssl genrsa -out mykey.key 2048

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "Scroll down the page until you see the Join the iOS Developer Program link as shown in the following screenshot".

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title via the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

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.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.1