Flex 4 Cookbook: Real-world recipes for developing Rich Internet Applications


With this collection of proven recipes, you have the ideal problem-solving guide for developing interactive Rich Internet Applications on the Adobe Flash Platform. You'll find answers to hundreds of common problems you may encounter when using Adobe Flex, Flex 4 Framework, or Flash Builder, Adobe's GUI-based development tool.

Flex 4 Cookbook has hands-on recipes for everything from Flex basics to solutions for working with visual components and data access, as well as tips on ...

See more details below
Other sellers (Paperback)
  • All (35) from $1.99   
  • New (14) from $28.28   
  • Used (21) from $1.99   
Flex 4 Cookbook: Real-world recipes for developing Rich Internet Applications

Available on NOOK devices and apps  
  • NOOK Devices
  • Samsung Galaxy Tab 4 NOOK 7.0
  • Samsung Galaxy Tab 4 NOOK 10.1
  • NOOK HD Tablet
  • NOOK HD+ Tablet
  • NOOK eReaders
  • NOOK Color
  • NOOK Tablet
  • Tablet/Phone
  • NOOK for Windows 8 Tablet
  • NOOK for iOS
  • NOOK for Android
  • NOOK Kids for iPad
  • PC/Mac
  • NOOK for Windows 8
  • NOOK for PC
  • NOOK for Mac
  • NOOK for Web

Want a NOOK? Explore Now

NOOK Book (eBook)
BN.com price
(Save 42%)$39.99 List Price


With this collection of proven recipes, you have the ideal problem-solving guide for developing interactive Rich Internet Applications on the Adobe Flash Platform. You'll find answers to hundreds of common problems you may encounter when using Adobe Flex, Flex 4 Framework, or Flash Builder, Adobe's GUI-based development tool.

Flex 4 Cookbook has hands-on recipes for everything from Flex basics to solutions for working with visual components and data access, as well as tips on application development, unit testing, and Adobe AIR. Each recipe provides an explanation of how and why it works, and includes sample code that you can use immediately. You'll get results fast, whether you're a committed Flex developer or still evaluating the technology. It's a great way to jumpstart your next web application.

Topics include:

  • Using Spark Component
  • Text Layout Framework
  • Groups and Layout
  • Spark List and ItemRenderer
  • Images, bitmaps, videos, and sounds
  • CSS, styling, and skinning
  • States and Effects
  • Working with Collections
  • Using DataBinding
  • Validation, formatting, and regular expressions
  • Using Charts
  • Services and Data Access
  • Using RSLs and Modules
  • Working with Adobe AIR 2.0
Read More Show Less

Product Details

  • ISBN-13: 9780596805616
  • Publisher: O'Reilly Media, Incorporated
  • Publication date: 6/24/2010
  • Edition number: 1
  • Pages: 736
  • Product dimensions: 7.00 (w) x 9.10 (h) x 1.60 (d)

Meet the Author

Josh Noble, a consultant, freelance developer, and Rich Internet Application designer, has taught coding and electronics to art and design students at the School of the Museum of Fine Arts in Boston. He works extensively with the tools discussed in this book, and teaches about their use in workshops and at colleges.

Todd Anderson is a Senior Software Developer in the Multimedia Platforms Group at Schematic Boston, and a co-author of "Adobe Air: Create - Modify - Reuse" (Wrox/Wiley).

Garth Braithwaite is an Interactive Engineer and Consultant for Media Blacksmith, a company he formed with a partner in 2007. He has been developing internet applications since 2004, and is the founder of VegasFlex, an official Adobe Flex User Group for the Greater Las Vegas Area, focusing on Flex, AIR, and Flash Catalyst. Garth works with CakePHP and JavaScript, and continues to improve his design skills. He is also an Adobe Certified Expert in Flex 3 and AIR.

Marco Casario used to program games in Basic for Commodore 64 before dedicating himself to Flash and Director projects for the Web. In 2005, he founded Comtaste, a company dedicated to exploring new frontiers in Rich Internet Applications and the convergence between the Web and mobile devices. He is founder of the biggest worldwide Flash Lite User Group and of AUG Italy, and the author of Flex Solutions: Essential Techniques for Flex 2 and Flex 3 Developers (FriendsofED). Marco has been a technical editor for Apress, Friends of ED, and WROX for books on Flash and Flex 2, and is a frequent presenter at conferences including Adobe Max, O'Reilly Web 2.0 Summit, and 360Flex Europe, among others.

Rich Tretola, an award-winning Flex developer, is the Rich Applications Technical Lead at Herff Jones Inc. He has been building internet apps for over a decade, and has worked with Flex since the original Royale beta was introduced in 2003. Rich is highly regarded in the Flex community as an expert in RIA, and is also an Adobe Community Expert. He has authored or co-authored a number of books on Flex and AIR, and has a popular Flex and AIR blog at Everything Flex.

Read More Show Less

Table of Contents

Who This Book Is For;
Who This Book Is Not For;
How This Book Is Organized;
Conventions Used in This Book;
Using Code Examples;
How to Use This Book;
O’Reilly Cookbooks;
Safari® Books Online;
How to Contact Us;
Chapter 1: Flex and ActionScript Basics;
1.1 Create a Flex Project in Flash Builder;
1.2 Create a Flex Library Project in Flash Builder;
1.3 Set Compiler Options in Flash Builder;
1.4 Compile a Flex Project Without Flash Builder;
1.5 Add an Event Listener in MXML;
1.6 Create Typed Vectors;
1.7 Use Event Bubbling;
1.8 Use Custom Events and Dispatch Data with Events;
1.9 Listen for a Keyboard Event;
1.10 Define Optional Parameters for Methods;
1.11 Define and Implement an Interface;
1.12 Access the Parent of a Flex Component;
Chapter 2: Containers;
2.1 Position Children Within a Container;
2.2 Dynamically Add and Remove Children;
2.3 Reorder Child Elements of a Container;
2.4 Display Children Using Data Items;
2.5 Use a Custom Item Renderer in a DataGroup;
2.6 Use Multiple Item Renderers in a DataGroup;
2.7 Enable Scrolling in a Container;
2.8 Scale Children of a Container;
2.9 Apply Skins to a Container;
2.10 Set the Background Image of a BorderContainer;
2.11 Use a Control Bar;
2.12 Modify Layout of Content Elements in a Panel;
2.13 Track Mouse Position Within a Container;
2.14 Drag and Drop Between Visual Containers;
2.15 Drag and Drop Between Data Containers;
2.16 Add a Spark Layout Container to a MX Navigation Container;
2.17 Create a Spark-Based ViewStack;
Chapter 3: Layout;
3.1 Position Children Linearly;
3.2 Switch Layout Management at Runtime;
3.3 Align and Size Children Within a Layout;
3.4 Lay Out Children Using Rows and Columns;
3.5 Size Children Uniformly;
3.6 Lazily Create and Recycle Children;
3.7 Create a Custom Layout;
3.8 Measure and Alter the Container Size;
3.9 Dynamically Change the Child Depth in the Layout;
3.10 Use Matrix3D to Apply Transformations Within a Layout;
3.11 Use TransformOffsets to Apply Transformations Within a Layout;
3.12 Create a Custom 3D Layout;
3.13 Programmatically Scroll Within a Layout;
3.14 Determine the Visibility of Elements in a Sequence-Based Layout;
Chapter 4: Graphics;
4.1 Size and Position a Graphic Element;
4.2 Use Path to Draw a Shape with Stroke and Fill;
4.3 Display Text in a Graphic Element;
4.4 Display Bitmap Data in a Graphic Element;
4.5 Display Gradient Text;
4.6 Apply Bitmap Data to a Graphic Element as a Mask;
4.7 Create a Custom Shape Element;
4.8 Create a Custom Standalone Graphic Component;
4.9 Define and Reuse Graphic Symbols;
Chapter 5: Components;
5.1 Handle a Button’s Click Event;
5.2 Create a Button Bar;
5.3 Load a External SWF;
5.4 Use a Calendar Date Input;
5.5 Create Event Handlers for Menu-Based Controls;
5.6 Display an Alert in an Application;
5.7 Display a Custom Pop Up in a Custom Component;
5.8 Detect a Mouse Click Outside a Pop Up to Close It;
5.9 Using s:Scroller to Create a Scrollable Container;
5.10 Handle focusIn and focusOut Events;
5.11 Open a DropDownList with a Keyboard Shortcut;
5.12 Grouping Radio Buttons;
5.13 Submit a Flex Form to a Server-Side Script;
Chapter 6: Skinning and Styles;
6.1 Create a Skin for s:Button;
6.2 Apply a Repeating Background Image to an Application;
6.3 Create a Skin for s:ButtonBar and s:ButtonBarButton;
6.4 Skin an s:DropDownList;
6.5 Skin a Spark Container;
6.6 Change the Appearance of Components Using Styles;
6.7 Apply Skins and Properties to Spark and MX Components with CSS;
6.8 Create a Button Component with an Icon;
6.9 Add Custom Style Properties;
6.10 Partially Embed Fonts with CSS;
Chapter 7: Text and TextFlows;
7.1 Create a TextFlow Object;
7.2 Generate a TextFlow Object from Another Source;
7.3 Create Links in a TextFlow;
7.4 Add Graphic Elements to a TextFlow;
7.5 Bind a Value to a s:TextInput Control;
7.6 Create a Custom Selection Style;
7.7 Style Links Within a TextFlow;
7.8 Locate Elements Within a TextFlow;
7.9 Determine All Fonts Installed on a User’s Computer;
7.10 Display Vertical Text in a TextArea;
7.11 Set the Selection in a TextArea;
7.12 Control the Appearance of the Selected Text;
7.13 Copy a Character as a Bitmap;
7.14 Create Linked Containers in a TextFlow;
7.15 Use a Custom Format Resolver;
7.16 Skin the TextArea Control;
7.17 Create Multiple Text Columns;
7.18 Highlight the Last Character in a TextFlow;
Chapter 8: Lists and ItemRenderers;
8.1 Create an Item Renderer for a Spark List;
8.2 Create an Editable List;
8.3 Scroll to an Item in a Spark List;
8.4 Change the Layout of a Spark List;
8.5 Create a Nested List;
8.6 Set XML Data for a Spark List;
8.7 Allow Only Certain Items in a Spark List to Be Selectable;
8.8 Format and Validate Data Added in a Spark List Item Editor;
8.9 Create a Right-Click Menu for a Spark List;
8.10 Enable Dragging in a Spark List;
8.11 Customize the Drop Indicator of a Spark List;
8.12 Display Asynchronously Loaded Data in a Spark List;
Chapter 9: DataGrid;
9.1 Create Custom Columns for a DataGrid;
9.2 Specify Sort Functions for DataGrid Columns;
9.3 Filter Items in a DataGrid;
9.4 Create Custom Headers for a DataGrid;
9.5 Handle Events from a DataGrid;
9.6 Enable Drag and Drop in a DataGrid;
9.7 Edit Items in a DataGrid;
9.8 Search Within a DataGrid and Autoscroll to the Match;
9.9 Generate a Summary for Flat Data by Using a Grouping Collection;
9.10 Create an Async Refresh for a Grouping Collection;
Chapter 10: Video;
10.1 Create a Basic Video Player;
10.2 Display Video Playback Progress;
10.3 Create a Skinned Video Player;
10.4 Display Streaming Video;
10.5 Display the Bytes Loaded of a Video;
10.6 Create a Basic Video Player Using the Open Source Media Framework;
10.7 Access and Display Cue Points Embedded in a Video File;
10.8 Create a Wrapper for the Open Source Media Framework;
10.9 Display Captions with the Open Source Media Framework;
Chapter 11: Animations and Effects;
11.1 Dynamically Set a Filter for a Component;
11.2 Call an Animation in MXML and in ActionScript;
11.3 Create Show and Hide Effects for a Component;
11.4 Define Keyframes for an Animation;
11.5 Create Parallel Series or Sequences of Effects;
11.6 Pause, Reverse, and Restart an Effect;
11.7 Set Effects for Adding a Component to or Removing One from a Parent Component;
11.8 Create Custom Animation Effects;
11.9 Use the DisplacementMapFilter Filter in a Flex Effect;
11.10 Use the Convolution Filter to Create an Animation;
11.11 Use Pixel Bender to Create a Transition;
Chapter 12: Collections;
12.1 Add, Remove, or Retrieve Data from an ArrayList;
12.2 Retrieve and Sort Data from an ArrayCollection;
12.3 Filter an ArrayCollection;
12.4 Determine When an Item Within an ArrayCollection Is Modified;
12.5 Create a GroupingCollection;
12.6 Create a Hierarchical Data Provider for a Control;
12.7 Navigate a Collection Object and Save Your Position;
12.8 Create a HierarchicalViewCollection Object;
12.9 Filter and Sort an XMLListCollection;
12.10 Sort on Multiple Fields in a Collection;
12.11 Sort on Dates in a Collection;
12.12 Create a Deep Copy of an ArrayCollection;
12.13 Use Data Objects with Unique IDs;
Chapter 13: Data Binding;
13.1 Bind to a Property;
13.2 Bind to a Function;
13.3 Create a Bidirectional Binding;
13.4 Bind to Properties by Using ActionScript;
13.5 Use Bindable Property Chains;
13.6 Bind to Properties on a XML Source by Using E4X;
13.7 Create Customized Bindable Properties;
13.8 Bind to a Generic Object;
13.9 Bind to Properties on a Dynamic Class;
Chapter 14: Validation, Formatting, and Regular Expressions;
14.1 Use Validators and Formatters with TextInput Controls;
14.2 Create a Custom Formatter;
14.3 Use Regular Expressions to Create an International Zip Code Validator;
14.4 Validate Combo Boxes and Groups of Radio Buttons;
14.5 Show Validation Errors by Using ToolTips in a Form;
14.6 Use Regular Expressions for Locating Email Addresses;
14.7 Use Regular Expressions for Matching Credit Card Numbers;
14.8 Use Regular Expressions for Validating ISBNs;
14.9 Create Regular Expressions by Using Explicit Character Classes;
14.10 Use Character Types in Regular Expressions;
14.11 Match Valid IP Addresses by Using Subexpressions;
14.12 Use Regular Expressions for Different Types of Matches;
14.13 Match Ends or Beginnings of Lines with Regular Expressions;
14.14 Use Back-References;
14.15 Use a Look-Ahead or Look-Behind;
Chapter 15: Working with Services and Server-Side Communication;
15.1 Configure a HTTPService;
15.2 Use RESTful Communication Between Flex Applications;
15.3 Communicate with a Service That Returns JSON-Formatted Data;
15.4 Configure Services for an Application Using BlazeDS;
15.5 Configure and Connect to a RemoteObject;
15.6 Use Publish/Subscribe Messaging for Chat Applications;
15.7 Use the IExternalizable Interface for Custom Serialization;
15.8 Track Results from Multiple Simultaneous Service Calls;
15.9 Register a Server-Side Data Type Within a Flex Application;
15.10 Communicate with a WebService;
15.11 Add a SOAP Header to a Request to a WebService;
15.12 Parse a SOAP Response from a WebService;
15.13 Communicate Securely with AMF by Using SecureAMFChannel;
15.14 Send and Receive Binary Data via a Binary Socket;
15.15 Communicate Using a XMLSocket;
15.16 Navigate a XML Document in E4X;
15.17 Use Regular Expressions in E4X Queries;
15.18 Add a XMLList to a XML Object;
15.19 Handle Namespaces in XML Returned by a Service;
15.20 Encode an ActionScript Data Object as XML;
15.21 Decode XML from a Web Service into Strongly Typed Objects;
Chapter 16: Browser Communication;
16.1 Link to an External URL;
16.2 Work with FlashVars;
16.3 Invoke JavaScript Functions from Flex;
16.4 Invoke ActionScript Functions from JavaScript;
16.5 Change the HTML Page Title via BrowserManager;
16.6 Parse the URL via BrowserManager;
16.7 Deep-Link to Data via BrowserManager;
16.8 Deep-Link Containers via BrowserManager;
Chapter 17: Modules and Runtime Shared Libraries;
17.1 Create a Runtime Shared Library;
17.2 Use Cross-Domain Runtime Shared Libraries;
17.3 Optimize a Runtime Shared Library;
17.4 Create a MXML-Based Module;
17.5 Create an ActionScript-Based Module;
17.6 Use ModuleLoader to Load Modules;
17.7 Use ModuleManager to Load Modules;
17.8 Load Modules from Different Servers;
17.9 Communicate with a Module;
17.10 Use Query Strings to Pass Data to Modules;
17.11 Use Linker Reports to Optimize Modules;
Chapter 18: AIR Basics;
18.1 Create and Run an AIR Application with Flash Builder 4;
18.2 Sign and Export an AIR Application;
18.3 Sign an AIR File with a Trusted Certificate;
18.4 Targeting a Specific Version of AIR;
18.5 Set the Application ID;
18.6 Set the Application Name and Filename;
18.7 Set the Application Version;
18.8 Edit the Application Description and Copyright Information;
18.9 Edit the Initial Window Settings;
18.10 Set the Installation Folder for an Application;
18.11 Set the Default Programs Menu Folder;
18.12 Set a Custom Application Icon;
18.13 Allow an AIR Application to Interact with the Browser;
18.14 Set the Application to Handle All Updates;
18.15 Determine the Application Version at Runtime;
18.16 Create Multilingual AIR Installations;
18.17 Create Applications with Update Capabilities;
18.18 Create Applications with Update Capabilities with a Custom Interface;
18.19 Package an Application in a Native Installer (.exe, .dmg, .rpm);
18.20 Include Native Code Within Your AIR Application;
Chapter 19: Working with Data in AIR;
19.1 Safeguard Files with the Encrypted Local Store;
19.2 Migrate Serialization Changes;
19.3 Create an In-Memory Database;
19.4 Encrypt a Database with a Password;
19.5 Use Parameters in Queries;
19.6 Include a Database in an Application;
19.7 Store Simple Relationships with an Object Relational Mapping;
Chapter 20: Operating System Integration with AIR;
20.1 Close All Open Windows at Once;
20.2 Add a Drop Shadow for a Custom Chrome Window;
20.3 Use Deferred Rendering with Clipboard Data;
20.4 Create Custom Clipboard Data Formats;
20.5 Assign Keyboard Shortcuts to Menu Items;
20.6 Notify the User Through the Dock (Mac) and the Taskbar (Windows);
20.7 Register Custom File Types;
20.8 Open a File with Its Default Application;
20.9 Check for Mounted and Unmounted Drives;
20.10 Obtain a List of Available External Drives;
20.11 Tell the Operating System That a File Has Been Downloaded from the Web;
20.12 Deploy an AIR Application as a Native Installer;
20.13 Create a HTTP Proxy Using the ServerSocket Class;
Chapter 21: Charting;
21.1 Create a Chart;
21.2 Add Effects to Charts;
21.3 Select Regions of a Chart;
21.4 Format Tick Marks for a Chart;
21.5 Create a Custom Label for a Chart;
21.6 Create a Drill-Down Effect for a Column Chart;
21.7 Skin Chart Items;
21.8 Use ActionScript to Dynamically Add Columns to and Remove Columns from a Chart;
21.9 Overlap Multiple ChartSeries;
21.10 Drag and Drop Items in a Chart;
21.11 Create an Editable Line Chart;
Chapter 22: Unit Testing with FlexUnit;
22.1 Create an Application That Uses the FlexUnit Framework;
22.2 Create an Application to Run FlexUnit Tests;
22.3 Create a FlexUnit Test Case;
22.4 Run Code Before and After Every Test;
22.5 Share Test Data Between Test Cases;
22.6 Handle Events in a Test Case;
22.7 Test Visual Components with FlexUnit;
22.8 Create Mock Objects for Testing;
22.9 Use Complex Assertions in a Test Case;
Chapter 23: Compiling, Debugging, and Deploying;
23.1 Use trace Statements Without Flash Builder;
23.2 Use the Component Compiler;
23.3 Install the Flex Ant Tasks;
23.4 Use mxmlc and Ant to Compile Flex Applications;
23.5 Use Ant to Compile and Deploy Flex Applications That Use RSLs;
23.6 Use Rake to Compile Flex Applications;
23.7 Create and Monitor Expressions in the Flash Builder Debugger;
23.8 Install the Ant View in the Standalone Version of Flash Builder;
23.9 Use ASDoc and Ant to Generate Documentation;
23.10 Use Express Install for Your Application;
23.11 Use Memory Profiling with Flash Builder to View Memory Snapshots;
23.12 Check the Performance of Specific Methods;
Chapter 24: Internationalization, Accessibility, and Printing;
24.1 Add an International Character Set to an Application;
24.2 Use a Resource Bundle to Localize an Application;
24.3 Use the ResourceManager for Localization;
24.4 Use Resource Modules for Localization;
24.5 Support Input Method Editor (IME) Devices;
24.6 Detect a Screen Reader;
24.7 Create a Tabbing Reading Order for Accessibility;
24.8 Print Selected Items in an Application;
24.9 Format Application Content for Printing;
24.10 Control Printing of Unknown-Length Content over Multiple Pages;
24.11 Add a Header and a Footer When Printing;

Read More Show Less

Customer Reviews

Be the first to write a review
( 0 )
Rating Distribution

5 Star


4 Star


3 Star


2 Star


1 Star


Your Rating:

Your Name: Create a Pen Name or

Barnes & Noble.com Review Rules

Our reader reviews allow you to share your comments on titles you liked, or didn't, with others. By submitting an online review, you are representing to Barnes & Noble.com that all information contained in your review is original and accurate in all respects, and that the submission of such content by you and the posting of such content by Barnes & Noble.com does not and will not violate the rights of any third party. Please follow the rules below to help ensure that your review can be posted.

Reviews by Our Customers Under the Age of 13

We highly value and respect everyone's opinion concerning the titles we offer. However, we cannot allow persons under the age of 13 to have accounts at BN.com or to post customer reviews. Please see our Terms of Use for more details.

What to exclude from your review:

Please do not write about reviews, commentary, or information posted on the product page. If you see any errors in the information on the product page, please send us an email.

Reviews should not contain any of the following:

  • - HTML tags, profanity, obscenities, vulgarities, or comments that defame anyone
  • - Time-sensitive information such as tour dates, signings, lectures, etc.
  • - Single-word reviews. Other people will read your review to discover why you liked or didn't like the title. Be descriptive.
  • - Comments focusing on the author or that may ruin the ending for others
  • - Phone numbers, addresses, URLs
  • - Pricing and availability information or alternative ordering information
  • - Advertisements or commercial solicitation


  • - By submitting a review, you grant to Barnes & Noble.com and its sublicensees the royalty-free, perpetual, irrevocable right and license to use the review in accordance with the Barnes & Noble.com Terms of Use.
  • - Barnes & Noble.com reserves the right not to post any review -- particularly those that do not follow the terms and conditions of these Rules. Barnes & Noble.com also reserves the right to remove any review at any time without notice.
  • - See Terms of Use for other conditions and disclaimers.
Search for Products You'd Like to Recommend

Recommend other products that relate to your review. Just search for them below and share!

Create a Pen Name

Your Pen Name is your unique identity on BN.com. It will appear on the reviews you write and other website activities. Your Pen Name cannot be edited, changed or deleted once submitted.

Your Pen Name can be any combination of alphanumeric characters (plus - and _), and must be at least two characters long.

Continue Anonymously
Sort by: Showing 1 Customer Reviews
  • Posted October 23, 2010

    more from this reviewer

    Written to save our time

    Flex 4 Cookbook is written to save our time. It consists of hundreds of tested recipes for developing Rich Internet Applications based on Adobe Flex 4 framework. It let's the reader to learn not only techniques of solving problems but also reasons behind them. In my opinion the Flex 4 Cookbook should be the most appropriate for intermediate Flex developers. There are a lot of code examples accompanying recipies which are ready to be taken advantage of in your applications. You can also find many references to additional on-line resources in this book allowing to suplement knowledge and understanding regarding a particular topic. The book is extremely useful and I recommend it to anyone who likes to have a solid off-line reference on the desk.

    Was this review helpful? Yes  No   Report this review
Sort by: Showing 1 Customer Reviews

If you find inappropriate content, please report it to Barnes & Noble
Why is this product inappropriate?
Comments (optional)