Flex 3 Cookbook
Code-Recipes, Tips, and Tricks for RIA Developers
By
Joshua Noble,
Todd Anderson
May 2008
Pages: 704
| Table of Contents
| Bonus Chapters
Table of Contents
-
Chapter 1 Flex and ActionScript Basics
-
Create a Flex Project in Flex Builder
-
Create a Flex Library Project in Flex Builder
-
Create an ActionScript Project
-
Set Compiler Options for the MXML Compiler in Flex
Builder
-
Compile a Flex Project Outside of Flex Builder
-
Add an Event Listener in MXML
-
Set Properties of a Child Defined in MXML in ActionScript
-
Define Arrays and Objects
-
Set the Scope of Variables in ActionScript
-
Create a Component in ActionScript
-
Use Event Bubbling
-
Use a Code-Behind Model to Separate MXML and ActionScript
-
Make Properties of a Component Bindable
-
Use Custom Events and Dispatch Data with Events
-
Listen for a Keyboard Event
-
Define Optional Parameters for Methods
-
Determine the Type of an Object
-
Define and Implement an Interface
-
Chapter 2 Menus and Controls
-
Listen to a Button Click
-
Create a Set of Buttons That Toggle
-
Use a ColorPicker to Set Canvas Color
-
Load a SWF by Using the SWFLoader
-
Set Tab Indexes for Components
-
Set a labelFunction for a Control
-
Provide Data for Menus
-
Dynamically Populate Menus
-
Create EventHandlers for Menu-Based Controls
-
Display an Alert in an Application
-
Use the Date from a Calendar Control
-
Display and Position Multiple Pop-ups
-
Create a Custom Border for a Pop-up Window
-
Handle focusIn and focusOut Events
-
Chapter 3 Containers
-
Position Children by Using Layout Management
-
Position and Size Containers via Percentage Positioning
-
Track Mouse Position Within Different Coordinate Systems
-
Dynamically Add and Remove Children from a Container
-
Use Constraint-Based Layout for Containers
-
Set Maximum and Minimum Sizes for Children Within
Containers
-
Specify Constraint Rows and Columns for a Container
-
Create Layout Flows for Text Using Constraints
-
Control Scrolling and Overflow Within Containers
-
Control the Layout of Box Components
-
Use Containers for Initialization
-
Create a TitleWindow
-
Control a ViewStack via a LinkBar
-
Bind the Selected Index of a ViewStack to a Variable
-
Use Delayed Instantiation to Improve Startup Time
-
Create and Control Resizable Containers
-
Create, Enable, and Disable TabControls Within a
TabNavigator
-
Create a TabNavigator with Closeable Tabs
-
Create and Control an Alert
-
Size and Position a Dialog Box Based on Its Calling
Component
-
Manage Multiple Pop-up Dialog Boxes
-
Scroll to a Specific Child in a Container
-
Create a Template Using IDeferredInstance
-
Manually Lay Out a Container
-
Measure and Alter Container Size
-
Control the Visibility and Layout of Children
-
Create a Tile Container with Simple Reorganization
-
Set a Background Image and Rounded Corners in an HBox
-
Control Positioning and Scrolling of Child Components
-
Chapter 4 Text
-
Correctly Set the Value of a Text Object
-
Bind a Value to TextInput
-
Create a Suggestive TextInput
-
Create an In-Place Editor
-
Determine All Fonts Installed on a User’s Computer
-
Create a Custom TextInput
-
Set the Style Properties for Text Ranges
-
Display Images and SWFs in HTML
-
Highlight User-Input Text in a Search Field
-
Manipulate Characters as Individual Graphics
-
Specify Styles for HTML in a TextField
-
Use the RichTextEditor
-
Apply Embedded Fonts with HTML
-
Add a Drop Shadow to Text in a Text Component
-
Find the Last Displayed Character in a TextArea
-
Chapter 5 Lists, Tiles, and Trees
-
Create an Editable List
-
Set Icons for Items in a List
-
Add Effects to a List to Indicate Changes
-
Set a Basic Item Renderer for a TileList
-
Set XML Data for a Tree
-
Create an Item Renderer for a Tree
-
Use Complex Data Objects in a Tree Control
-
Allow Only Certain Items in a List to Be Selectable
-
Format and Validate Data Added in a List’s Item Editor
-
Track All Selected Children in a TileList
-
Use and Display Null Items in an Item Renderer
-
Create a Right-Click Menu for a List
-
Customize the Appearance of a Selection in a List
-
Chapter 6 DataGrid and Advanced DataGrid
-
Create Custom Columns for a DataGrid
-
Specify Sort Functions for DataGrid Columns
-
Enable Multicolumn Sorting in a DataGrid
-
Filter Items in a DataGrid
-
Create Custom Headers for an AdvancedDataGrid
-
Handle Events from a DataGrid/AdvancedDataGrid
-
Select Items in an AdvancedDataGrid
-
Enable Drag-and-Drop in a DataGrid
-
Edit Items in a DataGrid
-
Search Within a DataGrid and Autoscroll to the Match
-
Generate a Summary for Flat Data by Using
GroupingCollection
-
Create an Async Refresh for a GroupingCollection
-
Chapter 7 Renderers and Editors
-
Create Your Own Renderers
-
Use the ClassFactory to Generate Renderers
-
Access the Component That Owns a Renderer
-
Create a Single Component to Act as Renderer and Editor
-
Create an Item Editor to Handle Data with Multiple Fields
-
Display SWF Objects as Items in a Menu by Using an Item
Renderer
-
Select a DataGrid Column with a CheckBox Header Renderer
-
Create a Self-Contained CheckBox itemRenderer for Use in a
DataGrid
-
Efficiently Set Images in a Renderer
-
Use Runtime Styling with itemRenderers and itemEditors
-
Use States and Transitions with an itemEditor
-
Create a CheckBox Tree Control
-
Resize Renderers Within a List
-
Chapter 8 Images, Bitmaps, Videos, Sounds
-
Load and Display an Image
-
Create a Video Display
-
Play and Pause an MP3 File
-
Create a Seek Bar for a Sound File
-
Blend Two Images
-
Apply a Convolution Filter to an Image
-
Send Video to an FMS Instance via a Camera
-
Access a User’s Microphone and Create a Sound Display
-
Smooth Video Displayed in a Flex Application
-
Check Pixel-Level Collisions
-
Read and Save a User’s Webcam Image
-
Use Blend Modes with Multiple Images
-
Handle Cue Points in FLV Data
-
Create a Video Scrubber
-
Read ID3 Data from an MP3 File
-
Display a Custom Loader while Loading Images
-
Enable Image Upload in Flex
-
Compare Two Bitmap Images
-
Chapter 9 Skinning and Styling
-
Use CSS to Style Components
-
Override the Default Application Style
-
Embed Styles by Using CSS
-
Override Base Style Properties
-
Customize Styles at Runtime
-
Load CSS at Runtime
-
Declare Styles at Runtime
-
Create Custom Style Properties for Components
-
Use Multiple Themes in the Same Application
-
Compile a Theme SWC
-
Use Embedded Fonts
-
Embed Fonts from a SWF File
-
Skin with Embedded Images
-
Apply Skins from a SWF File
-
Programmatically Skin a Component
-
Programmatically Skin a Stateful Control
-
Create Animated Skins from a SWF File
-
Customize the Preloader
-
Chapter 10 Dragging and Dropping
-
Use the DragManager Class
-
Specify a Drag Proxy
-
Drag and Drop Within a List
-
Drag and Drop Between Lists
-
Enable and Disable Drag Operations
-
Customize the DragImage of a List-Based Control
-
Customize the Drop Indicator of a List-Based Control
-
Chapter 11 States
-
Set Styles and Properties in a State
-
Create Transitions to Enter and Leave States
-
Use the AddChildAction and RemoveChildAction
-
Filter Transitions to Affect Only Certain Types of
Children
-
Apply Parts of a Transition to Certain Children
-
Base a State on Another State
-
Integrate View States with HistoryManagement
-
Use Deferred Instance Factories with States
-
Use Data Binding with Objects Added in a State
-
Add and Remove Event Listeners in State Changes
-
Add View States to a Flash Component
-
Work with State Change Events
-
Dynamically Generate and Use New States and Transitions
-
Create Custom Actions to Use in a State
-
Chapter 12 Effects
-
Call an Effect in MXML and in ActionScript
-
Build a Custom Effect
-
Create Parallel Series or Sequences of Effects
-
Pause, Reverse, and Restart an Effect
-
Create Custom Effect Triggers
-
Create Tween Effects
-
Use the DisplacementMapFilter Filter in a Flex Effect
-
Create an AnimateColor Effect
-
Use the Convolution Filter to Create a Tween
-
Chapter 13 Collections
-
Add, Sort, and Retrieve Data from an ArrayCollection
-
Filter an ArrayCollection
-
Determine When an Item Is Modified in an ArrayCollection
-
Create a GroupingCollection
-
Create a Hierarchical Data Provider for a Control
-
Navigate a Collection Object and Save Your Position
-
Create a HierarchicalViewCollection Object
-
Filter and Sort an XMLListCollection
-
Sort on Multiple Fields in a Collection
-
Sort on Dates in a Collection
-
Create a Deep Copy of an ArrayCollection
-
Use Data Objects with Unique IDs
-
Chapter 14 Data Binding
-
Bind to a Property
-
Bind to a Function
-
Create a Bidirectional Binding
-
Bind to Properties by Using ActionScript
-
Use Bindable Property Chains
-
Bind to Properties on XML by Using E4X
-
Create Customized Bindable Properties
-
Bind to a Generic Object
-
Bind to Properties on a Dynamic Class
-
Chapter 15 Validation, Formatting, and Regular Expressions
-
Use Validators and Formatters with TextInput and TextArea
Controls
-
Create a Custom Formatter
-
Create a More-International Zip Code Validator by Using Regular
Expressions
-
Create a Validator to Validate UPCs
-
Validate Combo Boxes and Groups of Radio Buttons
-
Show Validation Errors by Using ToolTips in a Form
-
Use Regular Expressions for Locating Email Addresses
-
Use Regular Expressions for Matching Credit Card Numbers
-
Use Regular Expressions for Validating ISBNs
-
Create Regular Expressions by Using Explicit Character
Classes
-
Use Character Types in Regular Expressions
-
Match Valid IP Addresses by Using Subexpressions
-
Use Regular Expressions for Different Types of Matches
-
Match Ends or Beginnings of Lines with Regular
Expressions
-
Use Back-References
-
Use a Look-Ahead or Look-Behind
-
Chapter 16 Charting
-
Create a Chart
-
Add Effects to Charts
-
Select Regions of a Chart
-
Format Tick Marks for a Chart
-
Create a Custom Label for a Chart
-
Create a Drill-Down Effect for a Columnar Chart
-
Skin Chart Items
-
Use ActionScript to Dynamically Add and Remove Columns for a
Chart
-
Overlap Multiple ChartSeries
-
Drag and Drop Items in a Chart
-
Create an Editable Line Chart
-
Chapter 17 SharedObjects
-
Create a SharedObject
-
Write Data into a SharedObject
-
Save a Local SharedObject
-
Read Data from a SharedObject
-
Remove Data from a SharedObject
-
Serialize Typed Objects
-
Access a SharedObject Between Multiple Flash Applications
-
Remember TextInput Values for Returning Users
-
Chapter 18 Working with Services and Server-Side Communication
-
Configure an HTTPService
-
Use RESTful Communication Between Flex Applications
-
Configure and Connect to a RemoteObject
-
Use Flex Remoting with AMFPHP 1.9
-
Use the IExternalizable Interface for Custom
Serialization
-
Track Results from Multiple Simultaneous Service Calls
-
Use Publish/Subscribe Messaging
-
Register a Server-Side Data Type Within a Flex
Application
-
Communicate with a WebService
-
Add a SOAP Header to a Request to a WebService
-
Parse a SOAP Response from a WebService
-
Communicate Securely with AMF by Using SecureAMFChannel
-
Send and Receive Binary Data via a Binary Socket
-
Communicate Using an XMLSocket
-
Chapter 19 XML
-
Load an XML File
-
Navigate an XML Document in E4X
-
Use Regular Expressions in E4X Queries
-
Add an XMLList to an XML Object
-
Bind to an XMLList or an E4X Query
-
Generate XML Objects from Arrays
-
Handle Namespaces in XML Returned by a Service
-
Encode an ActionScript Data Object as XML
-
Populate a Component with Complex XML Data
-
Decode XML from a Web Service into Strongly Typed Objects
-
Chapter 20 Browser Communication
-
Link to an External URL
-
Work with FlashVars
-
Invoke JavaScript Functions from Flex
-
Invoke ActionScript Functions from JavaScript
-
Change the HTML Page Title via BrowserManager
-
Parse the URL via BrowserManager
-
Deep-Link to Data via BrowserManager
-
Deep-Link Containers via BrowserManager
-
Implement Custom History Management
-
Chapter 21 Development Strategies
-
Use the Flex Component Kit to Create Components
-
Use the ContainerMovieClip to Create Flex Containers in
Flash
-
Import Components from Flash CS3
-
Get Started with the Cairngorm Architecture
-
Create a Cairngorm View, Event, and Model
-
Create Cairngorm Commands and a Business Delegate Class
-
Create a Cairngorm FrontController and a ServiceLocator
-
Generate an Application Structure with the Cairngen Framework
Generator
-
Learn Common Performance-Tuning Tricks
-
Create Custom Metadata Properties for a Component
-
Chapter 22 Modules and Runtime Shared Libraries
-
Create a Runtime Shared Library
-
Use Cross-Domain Runtime Shared Libraries
-
Use the Flex Framework as a Runtime Shared Library
-
Optimize a Runtime Shared Library
-
Create an MXML-Based Module
-
Create an ActionScript-Based Module
-
Load a Module by Using ModuleLoader
-
Use ModuleManager to Load Modules
-
Load Modules from Different Servers
-
Communicate with a Module
-
Pass Data to Modules by Using Query Strings
-
Optimize Modules by Using Linker Reports
-
Chapter 23 The Adobe Integrated Runtime API
-
Create an AIR Application Leveraging the Flex Framework
-
Understand the AIR Command-Line Tools
-
Open and Manage Native Windows
-
Create Native Menus
-
Read and Write to a File
-
Serialize Objects
-
Use the Encrypted Local Store
-
Browse for Files
-
Use the AIR File System Controls
-
Use the Native Drag-and-Drop API
-
Interact with the Operating System Clipboard
-
Add HTML Content
-
Cross-Script Between ActionScript and JavaScript
-
Work with Local SQL Databases
-
Detect and Monitor a Network Connection
-
Detect User Presence
-
Create System Tray and Dock Applications
-
Chapter 24 Unit Testing with FlexUnit
-
Create an Application That Uses the FlexUnit Framework
-
Create an Application to Run FlexUnit Tests
-
Create a FlexUnit Test Case
-
Add a Test Case to a Test Suite
-
Run Code Before and After Every Test
-
Share Test Data Between Test Cases
-
Handle Events in a Test Case
-
Test Visual Components with FlexUnit
-
Install and Configure Antennae
-
Generate Automated Test Suites
-
Chapter 25 Compiling and Debugging
-
Use Trace Statements Without Flex Builder
-
Use the Component Compiler
-
Install the Flex Ant Tasks
-
Use the compc and mxmlc Tasks in the Flex Ant Tasks
-
Compile and Deploy Flex Applications That Use RSLs
-
Create and Monitor Expressions in Flex Builder Debugging
-
Install the Ant View in the Stand-Alone Version of Flex
Builder
-
Create an Ant Build File for Automating Common Tasks
-
Compile a Flex Application by Using mxmlc and Ant
-
Generate Documentation by Using ASDoc and Ant
-
Compile Flex Applications by Using Rake
-
Use ExpressInstall for Your Application
-
Use Memory Profiling with Flex Builder 3 to View Memory
Snapshots
-
Chapter 26 Configuration, Internationalization, and Printing
-
Add an International Character Set to an Application
-
Use a Resource Bundle to Localize an Application
-
Use the ResourceManager for Localization
-
Use Resource Modules for Localization
-
Support IME Devices
-
Detect a Screen Reader
-
Create a Tabbing Reading Order for Accessibility
-
Print Selected Items in an Application
-
Format Application Content for Printing
-
Control Printing of Unknown Length Content over Multiple
Pages
-
Add a Header and a Footer When Printing
Return to Flex 3 Cookbook