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.
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.
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.
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).
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.
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 1–Chapter 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 3–Chapter 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 16–Chapter 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.
The following typographical conventions are used in this book:
Menu options are shown using the → character, such as File→Open.
Italic indicates new terms, URLs, email addresses, filenames, and file extensions.
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.
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.
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 firstname.lastname@example.org.
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.
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!
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:
Each problem addressed in an O’Reilly Cookbook is clearly stated, specific, and practical.
The solution is easy to understand and implement.
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.
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.
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)|
We have a web page for this book, where we list errata, examples, and any additional information. You can access this page here:
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.
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.
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.
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!