O'Reilly logo

Adobe AIR 1.5 Cookbook by Koen De Weggheleire, Koen DeWeggheleire, Marco Casario, David Tucker, Rich Tretola

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Preface

AIR is a powerful application runtime that lets developers build cross-platform desktop applications in multiple development environments: Flex, Flash, and JavaScript. AIR applications have all the features you would expect from a web application, but in addition, they provide functionality you would expect from a desktop application, including file system access, network monitoring, and an embedded database.

The Adobe AIR 1.5 Cookbook exists to help you solve problems. It is not here to explain everything about AIR but rather to be a guide and reference during your AIR development. Like every developer, you will inevitably encounter roadblocks during development, and this book will help you get over the hump.

The challenge in writing this book was to adequately discuss as much of the AIR APIs as possible for each of the three development environments: Flash, Flex, and JavaScript. Because of this, we have chosen to tackle specific areas of AIR development that we think are useful for developers. This book is meant to provide answers for beginning, intermediate, and advanced AIR developers.

AIR 1.5

This book introduces the newest version of the runtime, AIR 1.5. This is the fourth production release of AIR. This new version adds some great tools to the developer’s toolset. In addition to many bug fixes, this version includes several new features:

  • Support for Flash Player 10: The biggest addition to AIR 1.5 is the support for the new functionality in Flash Player 10 including 3D support, a new type engine, Pixel Bender filter integration, new Sound APIs, and much more.

  • SquirrelFish JavaScript interpreter: The new SquirrelFish JavaScript interpreter from the WebKit project provides extremely fast JavaScript execution within AIR.

    Note

    For more information on the SquirrelFish JavaScript interpreter, visit the WebKit blog here: http://webkit.org/blog/189/announcing-squirrelfish/.

  • Encrypted SQLite database support: Previously the only way to store encrypted data within the AIR API was to utilize the encrypted local store. Now AIR allows you to store structured relational data inside a SQLite database with AES encryption.

  • Extended language support: In addition to the languages that were supported in AIR 1.1, the new release of AIR supports Swedish, Dutch, Czech, Turkish, and Polish.

In this book, you will learn about many of the new features that are included with AIR 1.5.

Flash Player 10 Support

Although we cover the new areas of the AIR API, many of the features within Flash Player 10 are specific to a certain development environment. If you are interested in learning more about 3D support, the new type engine, or the new Sound APIs, be sure to check out the documentation for your development environment (whether Flex or Flash).

Bonus Chapter Online: Developing Mashup AIR Applications

We wanted to strike a balance between providing single solutions for problems and also helping developers build AIR applications for the first time. Because of this, we have provided an additional chapter online that will walk you through the process of creating four different mashup applications with Adobe AIR utilizing the solutions found in this book. This chapter should assist anyone new to AIR in developing a complete application. Go to http://www.oreilly.com/catalog/9780596522506 to read the bonus chapter.

Who This Book Is For

The Adobe AIR 1.5 Cookbook is for intermediate developers who already have an understanding of their specific development environment. That means Flash and Flex developers need to already have a good understanding of ActionScript 3. It also means that JavaScript developers need to have a working knowledge of the language. We have tried to provide background information where it is needed, but without a core understanding of your development environment, many solutions may not make sense.

Every recipe in this book contains code for each development environment. This means that if we are presenting a solution for the File API, we’ll provide both the ActionScript and JavaScript solutions. It also means that if we are discussing how to edit the application descriptor file, we will cover how to manually edit the XML file for Flex and JavaScript AIR applications as well as how to use the graphical tool provided in Flash.

Who This Book Is Not For

This book is not for developers who are new to ActionScript 3 or JavaScript. You will need to understand one of these languages. If you are new to Flex, you may want to read Programming Flex 3 by Joey Lott and Chafic Kazoun (O’Reilly, 2008), and if you are new to ActionScript 3, you may want to check out Learning ActionScript 3 by Rick Shupe and Zevan Rosser (O’Reilly, 2007). If you are new to JavaScript, you may want to read Learning JavaScript by Shelley Powers (O’Reilly, 2006). However, if you are familiar with ActionScript 3 or JavaScript but you have not worked with AIR previously, there is ample material to get you started developing your first application here within the book.

How This Book Is Organized

This book is a collection of recipes intended to be a reference that you can use in your AIR development. Each recipe in this book is a stand-alone solution. However, where needed, the recipe might reference other recipes in the book to provide additional information that may be needed to solve the problem. Our hope is that this book can be a valuable resource in your development by providing quick and easy-to-understand solutions to common problems you may encounter.

This book is essentially divided into four content groupings:

Chapter 1Chapter 2 give you basic information about how to develop AIR applications in the different development environments as well as how to configure an AIR application’s settings.
Chapter 3Chapter 15 provide solutions for working with the APIs that are included with AIR. This includes the file system, a network monitoring framework, the embedded SQLite database, and much more.
Chapter 16Chapter 17 give you the information needed to distribute and update your application. This includes using the AIR Update Framework and using the install badges.
The online chapter provides information needed to create mashup applications utilizing popular public APIs available to developers.

As mentioned earlier, each chapter provides information for each of the development environments.

Conventions Used in This Book

The following typographical conventions are used in this book:

Menu options

Menu options are shown using the → character, such as File→Open.

Italic

Italic indicates new terms, URLs, email addresses, filenames, and file extensions.

Constant width

This is used for program listings, as well as within paragraphs, to refer to program elements such as variable or function names, databases, data types, environment variables, statements, and keywords.

Constant width bold

This shows commands or other text that should be typed literally by you.

Constant width italic

This shows text that should be replaced with user-supplied values or by values determined by context.

This Book’s Example Files

You can download the example files for this book from this location:

http://www.oreilly.com/catalog/9780596522506

Where necessary, multiple code samples are provided for each recipe to correspond with the different development environments. Each sample will be separated into a folder for the specific environment. Each application should include the needed code for your environment as well as an application descriptor file.

Using the Code Examples

This book is here to help you get your job done. In general, you may use the code in this book in your programs and documentation. You do not need to contact us for permission unless you’re reproducing a significant portion of the code. For example, writing a program that uses several chunks of code from this book does not require permission. In addition, answering a question by citing this book and quoting example code does not require permission. However, selling or distributing a CD-ROM of examples from O’Reilly books does require permission. Incorporating a significant amount of example code from this book into your product’s documentation does require permission.

We appreciate, but do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN. For example: “Adobe AIR 1.5 Cookbook by David Tucker, Marco Casario, Koen De Weggheleire, and Rich Tretola. Copyright © 2009 David Tucker, Marco Casario, Koen DeWeggheleire, and Rich Tretola 978-0-596-522506.”

If you think your use of code examples falls outside fair use or the permission given here, feel free to contact us at .

How to Use This Book

Development rarely happens in a vacuum. In today’s world, email, Twitter, blog posts, co-workers, friends, and colleagues all play a vital role in helping you solve development problems. Consider this book yet another resource at your disposal to help you solve the development problems you will encounter. The content is arranged in such a way that solutions should be easy to find and easy to understand. However, this book does have a big advantage: it is available anytime of the day or night.

The Adobe AIR Cookbook Cook-Off

O’Reilly sponsored the Adobe AIR Cookbook Cook-Off, a chance for developers to submit recipes and win prizes. Many of the top entries have been included in this book, and the winning entry from Greg Jastrab can be found at Recipe 9-13. This contest was open to developers in the United States. Greg’s entry was chosen by a group of experts in the RIA development community. Congratulations, Greg!

O’Reilly Cookbooks

Looking for the right ingredients to solve a programming problem? Look no further than O’Reilly Cookbooks. Each cookbook contains hundreds of programming recipes and includes hundreds of scripts, programs, and command sequences you can use to solve specific problems.

The recipes you’ll find in an O’Reilly Cookbook follow a simple formula:

Problem

Each problem addressed in an O’Reilly Cookbook is clearly stated, specific, and practical.

Solution

The solution is easy to understand and implement.

Discussion

The discussion clarifies and explains the context for the problem and the solution. It also contains sample code to show you how to get the job done. Best of all, all the sample code you see in an O’Reilly Cookbook can be downloaded from the book’s website: http://www.oreilly.com/catalog/9780596522506.

To learn more about the O’Reilly Cookbook series or to find other Cookbooks that are up your alley, visit http://cookbooks.oreilly.com.

Safari® Books Online

Note

When you see a Safari® Books Online icon on the cover of your favorite technology book, that means the book is available online through the O’Reilly Network Safari Bookshelf.

Safari offers a solution that’s better than e-books. It’s a virtual library that lets you easily search thousands of top tech books, cut and paste code samples, download chapters, and find quick answers when you need the most accurate, current information. Try it for free at http://safari.oreilly.com.

How to Contact Us

Please address comments and questions concerning this book to the publisher:

O’Reilly Media, Inc
1005 Gravenstein Highway North
Sebastopol, CA 95472
800-998-9938 (in the United States or Canada)
707-829-0515 (international or local)
707-829-0104 (fax)

We have a web page for this book, where we list errata, examples, and any additional information. You can access this page here:

http://www.oreilly.com/catalog/9780596517359

Acknowledgments

While four of us get to share the cover of the book, we all know that none of this would have been possible if it had not been for the hard work of many people behind the scenes.

I certainly would like to thank everyone at O’Reilly who made this book possible. Steve Weiss gave each of us an opportunity on this book, and his input and guidance has been essential. Dennis Fitzgerald guided most of the development of the book, and his wisdom of this entire process was certainly needed. Also, special thanks are due to Linda Laflamme, Molly Sharp, and Kim Wimpsett, who worked tirelessly to be sure the book was ready on time and in good form. Their work in coordinating the editing effort with authors across two continents and multiple time zones is a testament to their organization, hard work, and skill. In addition, I want to thank Michael Koch, Amy Wong, and Ed Sullivan at Adobe for making the collaboration so easy.

While the authors have contributed some great solutions in this book, the technical editors contributed a great deal of insight and knowledge into making the recipes easy to understand and follow. The work of Ikezi Kamanu, Aaron Brownlee, and Peter Elst was essential in developing the final recipes. They provided insight into every aspect of the recipes including the code content, the code structure, the wording of solutions, and the structure of the chapters. This book is significantly better because of their input.

From David

This book was truly a collaborative effort between Marco, Rich, Koen, and me. I have learned something from each of them, and I am extremely grateful to have such a great group of coauthors for this book.

I want to thank Steve Weiss for giving me the opportunity to write this book. Steve has been someone who I learned a great deal from, and he has opened many doors for me that would have taken me decades to open by myself. In addition, I want to thank Michael Koch at Adobe for giving me many opportunities to contribute to the Adobe AIR Developer Center. Many highlights in my career were initially brought about by the opportunities he gave me to write. In addition, Rich Tretola has provided a great example to me of how to positively contribute to the developer community in many different ways. Also, I want to thank Jill Parks and Sam Skinner whose wisdom served me well during my time at Georgia Tech, when the book was just in its conceptual stage.

Finally, I have several people to thank in my family: Brian and Kevin for providing a great example to follow, Mom for always providing encouragement, Dad for exemplifying hard work and integrity, and Shannon for being an amazingly patient and supportive wife during the writing of this book. Most of all, to Jesus, who blesses Shannon and me beyond what we deserve, even with suffering, so we could learn to love Him more.

From Marco

My contribution to this book wouldn’t be possible without David Tucker, who gave me the possibility to collaborate with him on this awesome book, and of course without the support of the O’Reilly team, specifically, Steve Weiss and Dennis Fitzgerald. I’m amazed by the hard work done by the reviewers of this book. Thanks.

Finally, I would like to thank my girlfriend, Katia, for her patience with all the weekend hours spent on this book in the past months.

I dedicate this book to my mother who taught me to constantly challenge myself yet remain balanced.

From Koen

I really want to thank the dedicated people at O’Reilly for their professional help and guidance. I also want to thank my coauthors—David, Marco, and Rich—for the incredible amount of work they have put into this book to make it the best.

Of course, I also want to thank my colleagues, friends, and family for being supportive and for understanding why I sometimes didn’t have enough time for them.

I learned a lot from the community, and I still do, but I am very happy that I can give something back. You know...it’s all about giving back to the community!

Happy coding!

From Rich

Special thanks for the hard work of my coauthors—David, Marco, and Koen—and also Steve Weiss for asking me to be part of this book.

I would also like to thank my wife and best friend, Kim, and my daughters, Skye and Coral.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required