ebook img

Pro Android Flash: Building Rich Internet Flash and Javafx Apps for Android Smartphones and Tablets PDF

463 Pages·2011·44.54 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Pro Android Flash: Building Rich Internet Flash and Javafx Apps for Android Smartphones and Tablets

488 CHAPTER 9: Super Jumper: A 2D OpenGL ES Game For your convenience Apress has placed some of the front matter material after the index. Please use the Bookmarks and Contents at a Glance links to access them. Contents at a Glance Contents .............................................................................................................. v About the Authors ............................................................................................... x About the Technical Reviewer ........................................................................... xi Acknowledgments ............................................................................................ xii Foreword ......................................................................................................... xiii Introduction ...................................................................................................... xiv ■Chapter 1: Introducing Mobile Flash ............................................................... 1(cid:1) ■Chapter 2: Targeting Applications for the Mobile Profile .............................. 29(cid:1) ■Chapter 3: Building Flash and Flex Applications for Android ........................ 71(cid:1) ■Chapter 4: Graphics and Animation ............................................................. 121(cid:1) ■Chapter 5: Application Deployment and Publication ................................... 165(cid:1) ■Chapter 6: Adobe AIR and Native Android Apps .......................................... 199(cid:1) ■Chapter 7: Taking Advantage of Hardware Inputs ....................................... 243(cid:1) ■Chapter 8: Rich Media Integration ............................................................... 279(cid:1) ■Chapter 9: The Designer-Developer Workflow ............................................. 339(cid:1) ■Chapter 10: Performance Tuning ..................................................................359(cid:1) ■Chapter 11: Beyond Mobile: Tablets and TV .................................................399(cid:1) Index ............................................................................................................... 427 iv Introduction Our goal in writing this book was to open up the amazing world of mobile and device development to every single developer. You no longer need to learn a custom mobile programming language or be an expert in mobile application design to write good-looking, professional business applications. We believe that in the future, handsets and tablets will just be another deployment target for application developers—and with mobile Flash and Fle× technology, that future is now. For Those New to Flash This book starts out with a gentle introduction to the Flash tool chain and underlying technologies, and teaches the programming concepts by example. If you have experience in another C-based language, such as Java, JavaScript, or Objective-C, the pacing of this book will allow you to learn ActionScript and MXML while you are being introduced to Flash and Fle× mobile concepts and APIs. For Those New to Android The Flash and Fle× platform takes advantage of all the great features of Android, while insulating the programmer from having to deal with the complexities of the Android APIs and programming model. This means that with simple end-user knowledge of Android, you can be up and running as an application developer, publishing your very own Flash-based applications to Android Market. For the Rock Star Developers in All of Us Let’s face it—you didn’t pick up this book to be just another mobile developer. You want to stretch the limits of the platform, tap into features and capabilities that go beyond the average, and build apps that are impossibly cool. We are there with you, which is why we pushed the technology to its limits in developing this book. In the later chapters of this book, you will learn how to tap into native Android features, profile and tune your application for optimal performance, and deploy to a variety of different devices beyond simple handsets. xiv ■ INTRODUCTION Written by Your Team We are not your average, faceless authors who write books for a living. We are application developers and technology geeks just like you. We are invested in the technologies we discuss, the future of mobile development, and, most importantly, your success as a future Flash platform developer. All of the authors have a visible online presence with heavy community involvement, including leading Adobe user groups and technology evangelism. We are excited about the technology and accessible to questions, inquiries, and conversations. Rather than being just another author team, we are your own personal Flash development team. You will learn a lot from reading this book and coding the exercises, but don’t stop there. Start dialogs with other readers and Flash developers. Join a technology user group that specializes in Flash and Fle× technology. Reach out to us, the authors, with questions, ideas, concepts, and conjectures. Most importantly, make the technology your own. xv 1 Chapter Introducing Mobile Flash This book, Pro Android Flash, is the definitive guide to building rich, pervasive user experiences on mobile devices using the ubiquitous Flash Platform. We will show you how to leverage the powerful and mature technologies, frameworks, and tooling that make up the Flash Platform to build highly customized applications that take full advantage of all the mobile features that users demand from their devices. In reading this book, you will gain essential knowledge specific to targeting mobile Android devices, including device density, hardware inputs, native integration, and performance optimization. Why Android? There are many different mobile platforms to choose from and a plethora of mobile and tablet devices that are offered as options to consumers. Unlike the desktop, where there has been a considerable amount of consolidation and entrenchment, the mobile market is constantly evolving, with continual introduction of new devices and features. The obvious question is, which platform do you target? Our answer is to start with Android; then, by leveraging Flash technology, you avoid being locked into any particular platform. This book focuses on creating applications on devices running the Android operating system. The reason for this is that Android is quickly becoming the most popular mobile operating system in the world, with the best support for different hardware platforms and multiple form factors. According to the Nielsen Company, Android was the top choice among people who bought a smartphone in the second half of 2010. BlackBerry RIM and Apple iOS were in a statistical dead heat for second place, as shown in Figure 1–1. 1 2 CHAPTER 1: Introducing Mobile Flash Top 3 (cid:2)(cid:3)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:9)(cid:10)(cid:11)(cid:0)Operating System(cid:12) - Recent Acquirers Acquired Smartphone within 6 months, Jan 2010 to Aug 2010, USA 37% 34% 35% 32% Android OS 31% 32% 37% 26% 27% 25% Apple (cid:2)Phone OS 25% 26% RIM Black(cid:3)erry OS 21% 18% 14% Jan ‘10 Feb March April May June July Aug ‘10 Source: The Niels(cid:4)n Company Figure 1–1. Mobile OS traffic share in the United States1 This could be due to many different factors, including the fact that the platform is open source, which attracts device manufacturers, the relative freedom provided by Android Market, Google’s in-device application storefront, or the Google experience, which provides a seamless integration of Gmail, Google Maps, Gtalk, YouTube, and Google Search for end users. Regardless of the reason for Android’s popularity, chances are that a large percentage of your customers already have Android devices, or are considering purchasing one in the near future. At the same time, you are building on a platform with tremendous horizontal growth potential. Android is only the beginning for the Flash Platform, which benefits from an abstract virtual machine and APIs designed to work across multiple different operating systems and devices. You can take advantage of the same cross-platform transparency that Flash has brought to the desktop for all your mobile applications. Flash on Other Platforms Adobe started the Open Screen Project™,2 which is an industry-wide initiative to bring the benefits of Flash-powered applications to all the screens of your life. Adobe has already announced plans to support iOS, BlackBerry, Windows 7, and webOS, freeing you from platform lock-in. BlackBerry support is initially targeted at its Tablet OS, with the first available device being the BlackBerry PlayBook. Expect this support to be broadened in the future to include its other mobile devices. 1 Source: The Nielsen Company, http://nielsen.com/, 2010 2 Adobe, “Open Screen Project”, http://www.openscreenproject.org/ CHAPTER 1: Introducing Mobile Flash 3 Apple still has a restriction on running Flash in the browser, but it has opened up the App Store to allow third-party frameworks. This means that for iOS devices, you can deploy Flash as AIR applications on any iOS device, including the iPod touch, iPhone, and iPad. You also have the ability to deploy Flash web applications on any devices that support Flash in the browser. This includes Google TV, webOS, and Windows 7. In the future, expect to see even more platforms supporting Flash technology. Exploring Android Android is a full mobile stack that includes an operating system, services and infrastructure, and a core set of applications. While you do not need to be an expert in Android to effectively write and deploy Flash applications to Android devices, it does help to be familiar with how Android works. At its core, Android is based on the Linux operating system. It uses a modified version of the Linux kernel that has additional drivers and support for mobile hardware devices. On top of this, there is a set of libraries and core services that make up the base Android functionality. You will rarely interact directly with these libraries, but whenever you play a media file, browse to a web page, or even draw on the screen, you are going through one of the core Android libraries. Native Android applications are written using the Java programming language compiled down to Dalvik bytecodes. Dalvik is the name of Android’s special virtual machine that abstracts the hardware and supports advanced features like garbage collection. All the Android applications that you run (including Adobe AIR applications) execute within the Dalvik virtual machine. The full Android system architecture, broken down by the Linux Kernel, Libraries and Runtime, Application Framework, and Applications, is shown in Figure 1–2. 4 CHAPTER 1: Introducing Mobile Flash Figure 1–2. Android system architecture3 Besides having a very solid technology foundation, Android is continually evolving to embrace new hardware advances as they become available. Some of the current features of the Android platform include the following: (cid:1) Mobile browser: WebKit, a modern framework that supports all of the HTML5 proposed extensions and powers Android’s built-in browser (cid:1) Flash player: Starting with Android 2.2, you can run Flash content from within a web browser as a standard feature. (cid:1) Multitouch: All Android phones support touchscreens, and most have at least two touch points, which you can use for gesture recognition. (cid:1) Camera: Android phones are required to have a rear-facing camera, and many now include a front-facing camera as well. (cid:1) GPS, compass: All Android phones are required to have a three-way GPS and compass, which can be used for navigation applications. (cid:1) Multitasking: Android was the first mobile OS to expose application switching and background operations to installed applications. (cid:1) GSM telephony: Android devices that operate as phones give you the full capabilities of GSM telephony. 3 Reproduced from work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License: Google, “What is Android?”, http://developer.android.com/guide/basics/what-is- android.html, 2011 CHAPTER 1: Introducing Mobile Flash 5 (cid:1) Bluetooth, Wi-Fi, and USB: All Android devices come with Bluetooth and Wi-Fi for connectivity and a standard USB port for data transfer and debugging. (cid:1) Audio and video support: Android supports playback of most common audio and video formats that are in use on the Web, including MP3, Ogg, and H.264. These capabilities make the Android platform an exceptionally strong foundation for building mobile applications. Furthermore, Adobe Flash and AIR build on these base capabilities, making Flash a great platform to develop Android applications. The Flash Platform The Adobe Flash Platform is a complete system of integrated tools, frameworks, servers, services, and clients that run across operating systems, browsers, and devices. Companies across many industries use the Flash Platform to eliminate device and platform fragmentation, and develop consistent and expressive interactive user experiences regardless of device. Let’s take a look at the Flash Platform runtimes and tools. The Flash Runtime When creating a Flash application, you have the choice of two different deployment targets. The first is the Adobe Flash Player, which is an embedded browser plug-in, and the second is Adobe AIR, which is a stand-alone client runtime. Both of these options are available on desktop and mobile, and give you a lot of flexibility in tailoring your application deployment to the needs of your end users. Adobe Flash Player According to Adobe, Flash Player is installed on 98% of Internet-connected PCs and more than 450 million devices,4 offering the widest possible reach for applications that run on the client. For 2011, Adobe projects that Flash Player will be supported on more than 132 million smartphones, and it already comes pre-installed on over 20 million smartphones. An additional 50 new tablet devices are expected to support Flash Player in 2011 as well. Adobe Flash Player runs inside the browser in a secure container. This allows you to intermingle your Flash content with other web content written in HTML and JavaScript. You also get the benefit of installer-less operation. 4 Source: Adobe, “Benefits of rich internet applications”, www.adobe.com/resources/business/rich_internet_apps/benefits/#, 2009

Description:
Did you know you can take your Flash skills beyond the browser, allowing you to make apps for Android, iOS and the BlackBerry Tablet OS? Build dynamic apps today starting with the easy-to-use Android smartphones and tablets. Then, take your app to other platforms without writing native code. Pro And
See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.