Preface

This book is a long time in the making. We first started talking about this book several years ago, when Flex 1.0 first hit the market. We recognized that Flex was something important, yet we knew the product hadn’t matured enough at that point. However, we shortly thereafter heard the whispers of Flex 2, a new and improved Flex. After working with Flex 2, we were certain that this was going to revolutionize how we build applications. Running on a new virtual machine using new, streamlined metaphors, Flex 2 was light years ahead of anything we’d been working with to develop rich Internet applications. It was at that point that we got serious about writing this book.

You’ll learn shortly (starting in Chapter 1) what Flex 2 is and what you can do with it. However, briefly, Flex 2 is a framework and a set of tools (e.g., compilers) for building rich Internet applications. The framework is built on Flash Player technology, and it leverages a new (and lightning-fast) virtual machine built into Flash Player 9. This means Flex 2 applications can utilize all the functionality of Flash Player, such as animation, audio, video, request/response network data communication, real-time data communication, and much more. Furthermore, the Flex 2 framework vastly simplifies the creation of Flash Platform applications over previous options (Flash authoring, Flex 1.5, etc.).

Flex 2 is huge. Although the learning curve is not steep (it’s actually very easy to get started building Flex 2 applications), it is a long learning curve simply because of the massive amount of features packed into the framework. The official Flex documentation is quite good at telling you how to do something once you know what you’re looking for. Therefore, we made it our goal to present to you a book that fills in the gaps and helps you to get comfortable enough with Flex that you start to quickly know what you’re looking for. It is our intention in this book to provide you with practical advice from our own experiences learning Flex and drawing from our longer-term experiences building rich Internet applications using Flash Platform technologies.

We really feel that Flex 2 is a fantastic product and a great way to build applications. Although this is a technical book, we have poured our enthusiasm into our writing, and we’d like to think you will share our enthusiasm as you read this book. We feel that Flex 2 is a far better way to build rich Internet applications than any alternative currently on the market, and we feel that as you read this book and learn how to work with Flex, you’ll agree. With Flex, you have few (if any) problems involving cross-browser compatibility, network data communication is a snap, and the framework is built with solid object-oriented principals and standards in mind. In short, we feel it’s the fastest way to build the coolest, most stable applications.

Who This Book Is For

This book is intended for anyone looking to learn more about Flex 2. We recognize that the audience for this book represents a very diverse group of people with many different backgrounds. Some readers may have years of experience working with Flash Platform technologies, and others may be completely new to creating content that runs in Flash Player. Some readers may have computer science degrees or have worked in the software industry for years. Yet other readers may be self-taught. We have done our best to write a book that will cater to this diverse group.

However, be aware that in order to get the most from this book, it is best that you have a solid understanding of object-oriented principles, and that you are comfortable with understanding concepts such as runtime environments, byte code, and compilers. Furthermore, you will get the most from this book if you already know ActionScript, Java, C, C#, or another language that uses similar syntax. Although we do have a chapter dedicated to the basics of ActionScript (the programming language utilized by Flex applications), we don’t discuss any of the core APIs in detail. If you are interested in learning more about the ActionScript language, we encourage you to find a good ActionScript 3.0 book.

How This Book Is Organized

We spent a lot of time organizing and reorganizing the content of this book. Although there is likely no one way to present the content that will seem perfect to all readers, we’ve done our best to present it in an order that we feel will make sense.

Chapter 1, Introducing Flex

What is Flex? What are rich Internet applications (RIAs)? This chapter answers these questions, providing a context for the rest of the book.

Chapter 2, Building Applications with the Flex Framework

In this chapter, we discuss the various elements and steps involved in building a Flex application. Topics include using the compilers, building scripts, Flash Player security, deploying applications, and more.

Chapter 3, MXML

MXML is the declarative language used by Flex. In this chapter, you’ll learn the basics of MXML.

Chapter 4, ActionScript

ActionScript is the object-oriented programming language used by Flex. In this chapter, you’ll learn the basics of ActionScript 3.0.

Chapter 5, Framework Fundamentals

Flex vastly simplifies many aspects of building applications. Although you don’t often have to look under the hood, understanding the fundamentals of how the framework works is useful. In this chapter, you’ll learn about Flex application life cycles, bootstrapping, and more.

Chapter 6, Managing Layout

Flex provides many layout containers that allow you to quickly and easily create all sorts of layouts within your applications. This chapter explains how to work with those containers.

Chapter 7, Working with UI Components

In this chapter, you’ll learn about the user interface components (buttons, lists, menus, etc.) that are part of the Flex framework.

Chapter 8, Framework Utilities and Advanced Component Concepts

Once you’ve learned the basics of working with components, you’ll likely want to know how to expand on that knowledge. In this chapter, you’ll learn about such topics as tool tips, customizing lists, pop-up windows, and more.

Chapter 9, Working with Media

Flex allows you to include all sorts of assets and media in your applications, from images to animations to video and audio. In this chapter, you’ll learn how to work with these elements.

Chapter 10, Managing State

Flex applications and components within those applications can change from one view to another. Flex refers to these changes as states. This is sometimes as simple as adding a new component to a form, and it sometimes involves changing the entire contents of the screen. How to manage states is the subject of this chapter.

Chapter 11, Using Effects and Transitions

For animated changes between states or in response to user events or system events, Flex includes features called transitions and effects. You can learn about transitions and effects in this chapter.

Chapter 12, Working with Data

In this chapter, you’ll learn how to model data in Flex applications as well as how to link components so that they automatically update when data values change.

Chapter 13, Validating and Formatting Data

In this chapter, you’ll learn how to validate user input and how to format data such as numbers, phone numbers, and so on.

Chapter 14, Customizing Application Appearance

Customizing the appearance of Flex applications is important because it allows you to create applications that adhere to a corporate style guide or to a creative vision. This chapter explains how to change the appearance of Flex applications.

Chapter 15, Client Data Communication

Client data communication is any transfer of data into or out of Flash Player where the data remains on the client computer. Examples of this are communication between two or more Flex applications running on the same computer and storing persistent data on the computer. These topics are discussed in this chapter.

Chapter 16, Remote Data Communication

In this chapter, you’ll learn how to communicate from a Flex application running on a client computer to a remote data service. You’ll learn how to use XML, SOAP, AMF, and more.

Chapter 17, Application Debugging

Debugging applications is just as important as writing them. It’s unusual to build an application that has no errors, and therefore it’s crucial that you can track down those errors efficiently. In this chapter, you’ll learn how to work with the debugging features of Flex.

Chapter 18, Application Components

To make Flex application development manageable it’s important to know how to break up the application into discrete parts. This chapter discusses strategies for this.

Chapter 19, Building Custom Components

Custom components are an important part of Flex applications because they allow you to create elements that can be used, customized, and distributed. This chapter discusses the steps necessary to create custom components using the Flex framework.

What You Need to Use This Book

In order to use this book, you should have the Flex SDK and a text editor. Our intention with this book is that anyone with the (free) SDK can follow along. However, we recommend using Flex Builder for anyone serious about developing Flex applications. If you’re just starting with Flex, you might want to use the free trial version of Flex Builder initially to have the optimal experience building Flex applications.

Conventions Used in This Book

The following typographical conventions are used in this book:

Italic

Indicates new terms, URLs, email addresses, filenames, file extensions, pathnames, directories, and Unix utilities.

Constant width

Indicates commands, options, switches, variables, attributes, keys, functions, types, classes, namespaces, methods, modules, properties, parameters, values, objects, events, event handlers, XML tags, HTML tags, macros, the contents of files, or the output from commands.

Constant width bold

Shows commands or other text that should be typed literally by the user.

Constant width italic

Shows text that should be replaced with user-supplied values.

Tip

This icon signifies a tip, suggestion, or general note.

Using 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. Selling or distributing a CD-ROM of examples from O’Reilly books does require permission. Answering a question by citing this book and quoting example code does not 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: "Programming Flex 2, by Chafic Kazoun and Joey Lott. Copyright 2007 O’Reilly Media, Inc., 978-0-596-52689-4.”

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

Comments and Questions

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 at:

http://www.oreilly.com/catalog/059652689X/

To comment or ask technical questions about this book, send email to:

For more information about our books, conferences, Resource Centers, and the O’Reilly Network, see our web site at:

http://www.oreilly.com

Acknowledgments

This book, perhaps more than most, represents the efforts and contributions of many people. We’d like to acknowledge the following people.

Many thanks are due to the many people at O’Reilly who made this book possible. Special thanks to Steve Weiss and Audrey Doyle for their continued hard work and patience throughout the writing and editing of this book. They have each continuously gone above and beyond the call of duty, and we very much appreciate their efforts.

We’d also like to thank the many people at Adobe for not only working to create such a fantastic product as Flex 2, but also for answering our questions and helping us to see what things we might have missed. We’d especially like to thank a few select people: Matt Chotin, Alex Harui, Andrew Spaulding, and Manish Jethani, who not only answered our questions, but also took the time to review our chapters and provide valuable comments. We’re also very grateful to Mark Anders from Adobe for graciously accepting our invitation to write the Foreword to this book. We’re also thankful for the help of Mike Chambers throughout the planning and writing of this book.

The technical quality of this book is not just the work of the authors. The technical reviewers for this book are a fantastic group of people who have dedicated hours and hours of time to tell us when we’re wrong so that we can correct it before you can read it. The technical reviewers are the reason the code in this book works. The technical reviewers for this book (in addition to the Adobe folks mentioned in the preceding paragraph) include: Darron Schall, Keith Peters, Marc Leuchner, Sam Roach, Steven Schelter, Daniel Williams, Ben Stucki, Sam Neff, Eric Cancil, Larry Davidson, and Veronique Brossier.

From Chafic

I would like to thank Joey Lott for being an excellent coauthor. His experience in both the technical realm and the publishing industry helped me get through the long process of writing this book. I would also like to thank my family, friends, and the team at Atellis for their support through this experience; I made it! Finally, I would like to thank the O’Reilly team for believing in a first-time author, and in this book.

From Joey

I would also like to thank a few people. This is Chafic’s book, and I am grateful that he has trusted me enough to ask me to participate. Chafic has also pushed me to ensure that I do my very best. I’d also like to thank Robert Reinhardt for his show of faith in me all those years ago, giving me my first break in the writing business. Thanks go to all my colleagues at Schematic for their willingness to help with reviews and for asking all the right questions. Certainly I am grateful to my family and loved ones for their support and generosity of spirit.

Get Programming Flex 2 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.