Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL

About this Book

About this Book

Flex is an event-driven, object-oriented application framework and programming language that lets you build compelling and fluid Rich Internet Applications (RIAs) that run in the Adobe Flash environment.

Historically, the priority in web application development has been feature velocity and time to market, at the cost of usability to the end user. Flex lets you maintain that centrally deployed rapid-turnaround model, but it gives you the power to achieve usability at the same time.

Someone coming into Flex faces unique challenges. First, many developers aren’t used to an event-driven technology. They can understand it at a high level, but don’t truly get it for a long time. Until that happens, you can’t use the technology to its full capability; and, more important, you won’t be able to work as productively.

The second challenge stems from the fact that many developers have been working in their current technology stack for many years. Because people go with what they know, they tend to copy what they did in HTML over into Flex. That will work, but you’re limiting yourself creatively.

The third challenge is the complexity that comes as a result of Flex’s power. It’s not complicated per se, but a lot of web-application technologies are procedural and non-event-driven. The learning curve starts off slowly as you see the basic examples; but the moment you try to go one step further, it suddenly feels a lot harder.

Flex 4 in Action addresses these challenges and uses them as an underlying premise; it’s what makes the book unique. With the first challenge, the book emphasizes the event-driven nature of Flex by periodically reminding you how to leverage the event objects. We also help you catch on more quickly by showing many ways of doing the same thing along with the advantages and disadvantages of each.

Addressing the second challenge, we don’t negate your existing skills and we understand that you’re probably coming from another web technology. We came from there, too, and we know the mental leap it takes to break out of a mold you’re accustomed to. The book continuously provides suggestions how you can harness the power of a particular feature.

As far as the third challenge—complexity—is concerned, the mission of the book is to enable you to become an effective Flex developer in a short time. We do this through a combination of techniques that include using small examples you can relate to. We also leverage your existing skills by relating how you used to do things in other technologies with how you do them in Flex. The chapters are ordered in a logical progression of how you would go about building an application, starting with the easy stuff and ramping up your skills along the way.

You’re in good hands, and we’ll be your guide as you take your skills and career to the next level. The one thing we haven’t figured out is how to deal with all the fanfare that you’ll get from appreciative users. You’ll have to figure that out on your own!


Chapter 1 introduces Flex. It defines the problem and the approach Flex takes to solving it. Playing off that, we give you the business case that you’ll need to make in order to sell Flex to your department, customer, or clients. We describe how Flex works at a high level along with the concept of events, and where Flex sits in the overall suite of Adobe products.

Chapter 2 gets you started with building applications in Flex by introducing the toolset, environment, and languages. Events are fleshed out a bit more to ensure that your understanding continues to grow.

Chapter 3 is about Flex’s core language: ActionScript. This powerful ECMAScript-compliant, object-oriented language is what makes Flex possible. The chapter reviews data types, operators, loops, conditionals, and so on. You won’t get far without Action-Script, so it’s worth learning about it early on.

Chapter 4 addresses the layout of an application. It covers how you position display objects, as well as use containers to group visual objects together.

Chapter 5 begins by teaching you how to capture user input via forms. Flex has form inputs similar to those in HTML, but it also has a number of inputs that move beyond how they are captured in HTML.

Chapter 6 continues the topics from chapter 5 by discussing how Flex’s validators are used to validate user input. From a usability perspective, validating up front saves the user time and grief.

Chapter 7 flips things around by using formatters to format raw information (now that you have it). Often used alongside validators, formatters address the headache of having to format things yourself.

Chapter 8 explores the workhorse of Flex: list-based components. Lists are data-driven components that automatically build their display based on the data that they’re pointed at.

Chapter 9 adds onto chapter 8 by delving into the next generation of list-based components, which are part of Flex 4’s new Spark components.

Chapter 10 continues the topic of lists and focuses on how to customize them, from quick ‘n’ dirty approaches to using full-blown item renderers for customized display. Chapter 10 also introduces editors, which allow for inline editing.

Chapter 11 goes all out on events. By this point, we’ll have introduced how to use events in a minimal way; but this chapter takes it to the next level by going deep into how they work.

Chapter 12 shows you how to add navigation to your application so you can give your users the ability to switch between features.

Chapter 13 covers the use of pop-up windows as an extension to application navigation. It describes how your application can communicate with the pop-up by sending information back and forth.

Chapter 14 explores the subject of application flow and discusses a unique Flex feature known as view states. This mechanism can save you a lot of time by configuring the different views in your application; you can then switch from one view to another easily.

Chapter 15 begins the subject of working with data, particularly with getting data to and from your application from a back-end service. This includes connecting to servers that support Flex’s native binary protocol (AMF), XML over HTTP, and web services.

Chapter 16 covers objects and classes. Flex is an object-oriented language, after all. And although the comfort factor of sticking to its tag-based MXML language is nice, being aware of how ActionScript objects are created and used only adds to your powers.

Chapter 17 goes into detail about custom components, which is an area in which you’ll spend a lot of your development time. Custom components are your primary vehicle to break your application into small, manageable, reusable pieces.

Chapter 18 wraps up application structure with an overview of Flex’s reusability features such as sharing custom components across multiple projects and compiling shared libraries of functionality.

Chapter 19 takes application structure further by introducing formal architectural considerations, designing a Flex application, and utilizing the RobotLegs MVC framework as a means to accomplish a well architected application.

Chapter 20 begins the subject of customizing the experience. This topic includes using Flex’s version of CSS styles, skinning, and themes. Images and fonts are also covered.

Chapter 21 dives into one of Flex’s coolest features: effects. Effects add that “wow” factor to your application, and we also show how they can assist you in increasing usability.

Chapter 22 finishes our discussion of customization by showing you in detail how to use the drag-and-drop feature. This is a crowd favorite, but from the usability perspective you can save your users a few clicks by speeding up the workflow.

Chapter 23 is about charting. We review the various types of charts and give you advice about when to use each type. We also discuss the parts that make up a chart and how to customize it.

Chapter 24 covers testing and debugging. At this point, you’re wrapping up the project and entering the QA cycle. Knowing how to debug applications and how to isolate issues is key. Flex comes with a number of built-in features, but we also review third-party tools.

Chapter 25 wraps up the project with the final steps. These involve adding print capabilities to your application, using wrappers to load your application, and developing a release plan to deploy a production build of the software.

Chapter 26 is a bonus add-on chapter, available online, which dives into working with XML. XML is a ubiquitous language; but Flex is the first to support the E4X syntax, which lets you work with XML as if it were a native Flex object. The chapter is available for download from the publisher’s website at

Code downloads and conventions

This book contains numerous examples of Flex, ActionScript, and XML code. All code examples can be found at the book’s website: as well as at the publisher’s website:

The following conventions are used throughout the book:

  • Italic typeface is used to introduce new terms.

  • Courier/Fixed-Width typeface is used for code samples, as well as elements, attributes/properties, function names, and class names. MXML components, when used by name, won’t use this typeface in text unless they’re referenced as part of an actual code snippet.

  • Bold and Italic face Courier/Fixed-Width typeface is used to highlight portions within code.

  • Code annotations accompany many segments of code. Certain annotations are marked with bullets such as . These annotations have further explanations that follow the code.

  • The > symbol is used to indicate menu items that should be selected in sequence.

  • Code-line continuations use the symbol.

Author Online

Purchase of Flex 4 in Action includes free access to a private web forum run by Manning Publications where you can make comments about the book, ask questions, and receive help from the authors and from other users. To access the forum and subscribe to it, point your web browser to This page provides information on how to get on the forum once you are registered, what kind of help is available, and the rules of conduct on the forum.

Manning’s commitment to our readers is to provide a venue where a meaningful dialogue between individual readers and between readers and the authors can take place. It is not a commitment to any specific amount of participation on the part of the authors, whose contribution to the AO remains voluntary (and unpaid). We suggest you try asking the authors some challenging questions lest their interest stray!

The Author Online forum and the archives of previous discussions will be accessible from the publisher’s website as long as the book is in print.

About the authors

TARIQ AHMED is an accomplished web application pioneer with over 15 years of experience introducing next generation web technologies to companies such as Bell Canada and REUTERS. He was first to introduce eBay to Adobe Flex, and saw it proliferate to other teams. As an Adobe Flex Community Expert, Tariq evangelizes the technology and supports the community, particularly through his Community Flex (CFLEX.Net) site and his personal blog ( He is currently the Manager of Product Development at Amcom Technology, managing a team of RIA Engineers and Business Intelligence Analysts.

DAN ORLANDO is a recognized RIA Architect, specializing in enterprise class Flex and AIR applications. Dan is often called on as a resource for information on topics involving bleeding edge technology platforms for radio interviews and print publications, which include: PHP Architect magazine, Flex and Flash Developer Magazine, Amazon Web Services Developer Connection, Adobe Developer Connection, IBM developer-Works,, and many others.

JOHN C. BLAND II is founder of Katapult Media Inc. which focuses on software and web development using technologies such as ColdFusion, the Flash Platform, PHP, Java, the .NET Platform, and Objective-C (iPhone, Mac OSX, etc). Through Katapult, he works diligently on custom software and web products for small and large clients throughout the world. As a 2009 Adobe Community Expert, John continues to put back into the community which helped mold him into the developer he is today. John blogs regularly on his Geek Life blog:

JOEL HOOKS is a Flash Platform developer with experience in Actionscript 3, Flex, and Python. Joel spent the first 13 years of his professional career as a 3d animator and graphic designer working on computer based training applications from that perspective. His interest in programming goes as far back as “TELL TURTLE” and he has always been interested in the technological challenges related to developing software. With the introduction of Actionscript 3, Joel finally found a platform that allows him to architect useful tools while fully leveraging his experience as a visual artist. Joel is passionate about technology and enjoys exploring the landscape of frameworks, libraries, and tools that make his work constantly fun and challenging.

  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint