SlideShare a Scribd company logo
Visit https://ebookfinal.com to download the full version and
explore more ebooks
Flex 3 Cookbook Code Recipes Tips and Tricks for
RIA Developers 1st Edition Joshua Noble
_____ Click the link below to download _____
https://ebookfinal.com/download/flex-3-cookbook-code-
recipes-tips-and-tricks-for-ria-developers-1st-edition-
joshua-noble/
Explore and download more ebooks at ebookfinal.com
Here are some suggested products you might be interested in.
Click the link to download
Getting Started with Flex 3 An Adobe Developer Library
Pocket Guide for Developers 1st Edition Jack Herrington D.
https://ebookfinal.com/download/getting-started-with-flex-3-an-adobe-
developer-library-pocket-guide-for-developers-1st-edition-jack-
herrington-d/
Adobe Photoshop CS3 Top 100 Simplified Tips Tricks Top 100
Simplified Tips Tricks 1st Edition Lynette Kent
https://ebookfinal.com/download/adobe-photoshop-
cs3-top-100-simplified-tips-tricks-top-100-simplified-tips-tricks-1st-
edition-lynette-kent/
Oracle Internals Tips Tricks and Techniques for DBAs 1st
Edition Donald K. Burleson
https://ebookfinal.com/download/oracle-internals-tips-tricks-and-
techniques-for-dbas-1st-edition-donald-k-burleson/
Adobe flex 3 0 for dummies 1st ed Edition Doug Mccune
https://ebookfinal.com/download/adobe-flex-3-0-for-dummies-1st-ed-
edition-doug-mccune/
100 Game Design Tips Tricks 1st Edition Wlad Marhulets
https://ebookfinal.com/download/100-game-design-tips-tricks-1st-
edition-wlad-marhulets/
The Allotment Cookbook Through the Year Over 200 Recipes
Pick Stores Tips Preserving Ideas Caroline Bretherton
https://ebookfinal.com/download/the-allotment-cookbook-through-the-
year-over-200-recipes-pick-stores-tips-preserving-ideas-caroline-
bretherton/
GPU Gems Programming Techniques Tips and Tricks for Real
Time Graphics 1st Edition Randima Fernando
https://ebookfinal.com/download/gpu-gems-programming-techniques-tips-
and-tricks-for-real-time-graphics-1st-edition-randima-fernando/
Multicore Software Development Techniques Applications
Tips and Tricks 1st Edition Oshana
https://ebookfinal.com/download/multicore-software-development-
techniques-applications-tips-and-tricks-1st-edition-oshana/
Mac Os Catalina Tricks And Tips 2020 2nd Edition Techgo
https://ebookfinal.com/download/mac-os-catalina-tricks-and-
tips-2020-2nd-edition-techgo/
Get Flex 3 Cookbook Code Recipes Tips and Tricks for RIA Developers 1st Edition Joshua Noble free all chapters
Flex 3 Cookbook Code Recipes Tips and Tricks for RIA
Developers 1st Edition Joshua Noble Digital Instant
Download
Author(s): Joshua Noble, Todd Anderson
ISBN(s): 9780596529857, 0596529856
Edition: 1
File Details: PDF, 6.37 MB
Year: 2008
Language: english
Flex 3 Cookbook
by Joshua Noble; Todd Anderson
Publisher: O'Reilly
Pub Date: May 6, 2008
Print ISBN-13: 978-0-596-52985-7
Pages: 704
Table of Contents
| Index
Overview
The best way to show off a powerful new technology is to demonstrate real-world results with it, and that's
exactly what Adobe and O'Reilly have done with Flex 3. Through it's Flex Cookbook website, Adobe invited users
of the Flex 3 beta to post their own solutions for working with this technology, using O'Reilly's popular problem-
solution-discussion format. Website monitors (and authors) Joshua Noble and Todd Anderson chose the most
useful solutions for Flex 3 Cookbook. This highly practical book contains more than 200 proven recipes for
developing interactive Rich Internet Applications and Web 2.0 sites, including several contributed by Noble,
Anderson, and other Flex experts. You'll find everything from Flex basics and working with menus and controls,
to methods for compiling, deploying, and configuring Flex applications. Each recipe features a discussion of how
and why it works, and many of them offer sample code that you can put to use immediately. Topics include:
Menus and controls
Containers and dialogues
Working with Text
List, tiles, trees, and repeaters
DataGrid and Advanced DataGrid
Renderers
Images, videos, and sounds
CSS and skinning
Building components
States and effects
Collections, arrays, and DataProviders
Flex 3 Cookbook
by Joshua Noble; Todd Anderson
Publisher: O'Reilly
Pub Date: May 6, 2008
Print ISBN-13: 978-0-596-52985-7
Pages: 704
Table of Contents
| Index
Overview
The best way to show off a powerful new technology is to demonstrate real-world results with it, and that's
exactly what Adobe and O'Reilly have done with Flex 3. Through it's Flex Cookbook website, Adobe invited users
of the Flex 3 beta to post their own solutions for working with this technology, using O'Reilly's popular problem-
solution-discussion format. Website monitors (and authors) Joshua Noble and Todd Anderson chose the most
useful solutions for Flex 3 Cookbook. This highly practical book contains more than 200 proven recipes for
developing interactive Rich Internet Applications and Web 2.0 sites, including several contributed by Noble,
Anderson, and other Flex experts. You'll find everything from Flex basics and working with menus and controls,
to methods for compiling, deploying, and configuring Flex applications. Each recipe features a discussion of how
and why it works, and many of them offer sample code that you can put to use immediately. Topics include:
Menus and controls
Containers and dialogues
Working with Text
List, tiles, trees, and repeaters
DataGrid and Advanced DataGrid
Renderers
Images, videos, and sounds
CSS and skinning
Building components
States and effects
Collections, arrays, and DataProviders
DataBinding
Validation/formatters
Charting and data visualization
State management, SharedObjects and LocalConnection
Working with services and ServerSide communication
Working with XML
Communicating with the browser
Application development strategies
Runtime and dynamic shared libraries and modules
Working with Adobe AIR
Whether you're a committed Flex developer, or still evaluating the technology, you'll discover how to get quick
results with Flex 3 using these these recipes. Now that Flex is an open source framework, the user community
will continue to supply solutions to extend and improve the technology. This Cookbook offers you the cream of
the crop.
Flex 3 Cookbook
by Joshua Noble; Todd Anderson
Publisher: O'Reilly
Pub Date: May 6, 2008
Print ISBN-13: 978-0-596-52985-7
Pages: 704
Table of Contents
| Index
Copyright
Preface
Chapter 1. Flex and ActionScript Basics
Recipe 1.1. Create a Flex Project in Flex Builder
Recipe 1.2. Create a Flex Library Project in Flex Builder
Recipe 1.3. Create an ActionScript Project
Recipe 1.4. Set Compiler Options for the MXML Compiler in Flex Builder
Recipe 1.5. Compile a Flex Project Outside of Flex Builder
Recipe 1.6. Add an Event Listener in MXML
Recipe 1.7. Set Properties of a Child Defined in MXML in ActionScript
Recipe 1.8. Define Arrays and Objects
Recipe 1.9. Set the Scope of Variables in ActionScript
Recipe 1.10. Create a Component in ActionScript
Recipe 1.11. Use Event Bubbling
Recipe 1.12. Use a Code-Behind Model to Separate MXML and ActionScript
Recipe 1.13. Make Properties of a Component Bindable
Recipe 1.14. Use Custom Events and Dispatch Data with Events
Recipe 1.15. Listen for a Keyboard Event
Recipe 1.16. Define Optional Parameters for Methods
Recipe 1.17. Determine the Type of an Object
Recipe 1.18. Define and Implement an Interface
Chapter 2. Menus and Controls
Recipe 2.1. Listen to a Button Click
Recipe 2.2. Create a Set of Buttons That Toggle
Recipe 2.3. Use a ColorPicker to Set Canvas Color
Recipe 2.4. Load a SWF by Using the SWFLoader
Recipe 2.5. Set Tab Indexes for Components
Recipe 2.6. Set a labelFunction for a Control
Recipe 2.7. Provide Data for Menus
Recipe 2.8. Dynamically Populate Menus
Recipe 2.9. Create EventHandlers for Menu-Based Controls
Recipe 2.10. Display an Alert in an Application
Recipe 2.11. Use the Date from a Calendar Control
Recipe 2.12. Display and Position Multiple Pop-ups
Recipe 2.13. Create a Custom Border for a Pop-up Window
Recipe 2.14. Handle focusIn and focusOut Events
Chapter 3. Containers
Recipe 3.1. Position Children by Using Layout Management
Recipe 3.2. Position and Size Containers via Percentage Positioning
Recipe 3.3. Track Mouse Position Within Different Coordinate Systems
Recipe 3.4. Dynamically Add and Remove Children from a Container
Recipe 3.5. Use Constraint-Based Layout for Containers
Recipe 3.6. Set Maximum and Minimum Sizes for Children Within Containers
Recipe 3.7. Specify Constraint Rows and Columns for a Container
Recipe 3.8. Create Layout Flows for Text Using Constraints
Recipe 3.9. Control Scrolling and Overflow Within Containers
Recipe 3.10. Control the Layout of Box Components
Recipe 3.11. Use Containers for Initialization
Recipe 3.12. Create a TitleWindow
Recipe 3.13. Control a ViewStack via a LinkBar
Recipe 3.14. Bind the Selected Index of a ViewStack to a Variable
Recipe 3.15. Use Delayed Instantiation to Improve Startup Time
Recipe 3.16. Create and Control Resizable Containers
Recipe 3.17. Create, Enable, and Disable TabControls Within a TabNavigator
Recipe 3.18. Create a TabNavigator with Closeable Tabs
Recipe 3.19. Create and Control an Alert
Recipe 3.20. Size and Position a Dialog Box Based on Its Calling Component
Recipe 3.21. Manage Multiple Pop-up Dialog Boxes
Recipe 3.22. Scroll to a Specific Child in a Container
Recipe 3.23. Create a Template Using IDeferredInstance
Recipe 3.24. Manually Lay Out a Container
Recipe 3.25. Measure and Alter Container Size
Recipe 3.26. Control the Visibility and Layout of Children
Recipe 3.27. Create a Tile Container with Simple Reorganization
Recipe 3.28. Set a Background Image and Rounded Corners in an HBox
Recipe 3.29. Control Positioning and Scrolling of Child Components
Chapter 4. Text
Recipe 4.1. Correctly Set the Value of a Text Object
Recipe 4.2. Bind a Value to TextInput
Recipe 4.3. Create a Suggestive TextInput
Recipe 4.4. Create an In-Place Editor
Recipe 4.5. Determine All Fonts Installed on a User's Computer
Recipe 4.6. Create a Custom TextInput
Recipe 4.7. Set the Style Properties for Text Ranges
Recipe 4.8. Display Images and SWFs in HTML
Recipe 4.9. Highlight User-Input Text in a Search Field
Recipe 4.10. Manipulate Characters as Individual Graphics
Recipe 4.11. Specify Styles for HTML in a TextField
Recipe 4.12. Use the RichTextEditor
Recipe 4.13. Apply Embedded Fonts with HTML
Recipe 4.14. Add a Drop Shadow to Text in a Text Component
Recipe 4.15. Find the Last Displayed Character in a TextArea
Chapter 5. Lists, Tiles, and Trees
Recipe 5.1. Create an Editable List
Recipe 5.2. Set Icons for Items in a List
Recipe 5.3. Add Effects to a List to Indicate Changes
Recipe 5.4. Set a Basic Item Renderer for a TileList
Recipe 5.5. Set XML Data for a Tree
Recipe 5.6. Create an Item Renderer for a Tree
Recipe 5.7. Use Complex Data Objects in a Tree Control
Recipe 5.8. Allow Only Certain Items in a List to Be Selectable
Recipe 5.9. Format and Validate Data Added in a List's Item Editor
Recipe 5.10. Track All Selected Children in a TileList
Recipe 5.11. Use and Display Null Items in an Item Renderer
Recipe 5.12. Create a Right-Click Menu for a List
Recipe 5.13. Customize the Appearance of a Selection in a List
Chapter 6. DataGrid and Advanced DataGrid
Recipe 6.1. Create Custom Columns for a DataGrid
Recipe 6.2. Specify Sort Functions for DataGrid Columns
Recipe 6.3. Enable Multicolumn Sorting in a DataGrid
Recipe 6.4. Filter Items in a DataGrid
Recipe 6.5. Create Custom Headers for an AdvancedDataGrid
Recipe 6.6. Handle Events from a DataGrid/AdvancedDataGrid
Recipe 6.7. Select Items in an AdvancedDataGrid
Recipe 6.8. Enable Drag-and-Drop in a DataGrid
Recipe 6.9. Edit Items in a DataGrid
Recipe 6.10. Search Within a DataGrid and Autoscroll to the Match
Recipe 6.11. Generate a Summary for Flat Data by Using GroupingCollection
Recipe 6.12. Create an Async Refresh for a GroupingCollection
Chapter 7. Renderers and Editors
Recipe 7.1. Create Your Own Renderers
Recipe 7.2. Use the ClassFactory to Generate Renderers
Recipe 7.3. Access the Component That Owns a Renderer
Recipe 7.4. Create a Single Component to Act as Renderer and Editor
Recipe 7.5. Create an Item Editor to Handle Data with Multiple Fields
Recipe 7.6. Display SWF Objects as Items in a Menu by Using an Item Renderer
Recipe 7.7. Select a DataGrid Column with a CheckBox Header Renderer
Recipe 7.8. Create a Self-Contained CheckBox itemRenderer for Use in a DataGrid
Recipe 7.9. Efficiently Set Images in a Renderer
Recipe 7.10. Use Runtime Styling with itemRenderers and itemEditors
Recipe 7.11. Use States and Transitions with an itemEditor
Recipe 7.12. Create a CheckBox Tree Control
Recipe 7.13. Resize Renderers Within a List
Chapter 8. Images, Bitmaps, Videos, Sounds
Recipe 8.1. Load and Display an Image
Recipe 8.2. Create a Video Display
Recipe 8.3. Play and Pause an MP3 File
Recipe 8.4. Create a Seek Bar for a Sound File
Recipe 8.5. Blend Two Images
Recipe 8.6. Apply a Convolution Filter to an Image
Recipe 8.7. Send Video to an FMS Instance via a Camera
Recipe 8.8. Access a User's Microphone and Create a Sound Display
Recipe 8.9. Smooth Video Displayed in a Flex Application
Recipe 8.10. Check Pixel-Level Collisions
Recipe 8.11. Read and Save a User's Webcam Image
Recipe 8.12. Use Blend Modes with Multiple Images
Recipe 8.13. Handle Cue Points in FLV Data
Recipe 8.14. Create a Video Scrubber
Recipe 8.15. Read ID3 Data from an MP3 File
Recipe 8.16. Display a Custom Loader while Loading Images
Recipe 8.17. Enable Image Upload in Flex
Recipe 8.18. Compare Two Bitmap Images
Chapter 9. Skinning and Styling
Recipe 9.1. Use CSS to Style Components
Recipe 9.2. Override the Default Application Style
Recipe 9.3. Embed Styles by Using CSS
Recipe 9.4. Override Base Style Properties
Recipe 9.5. Customize Styles at Runtime
Recipe 9.6. Load CSS at Runtime
Recipe 9.7. Declare Styles at Runtime
Recipe 9.8. Create Custom Style Properties for Components
Recipe 9.9. Use Multiple Themes in the Same Application
Recipe 9.10. Compile a Theme SWC
Recipe 9.11. Use Embedded Fonts
Recipe 9.12. Embed Fonts from a SWF File
Recipe 9.13. Skin with Embedded Images
Recipe 9.14. Apply Skins from a SWF File
Recipe 9.15. Programmatically Skin a Component
Recipe 9.16. Programmatically Skin a Stateful Control
Recipe 9.17. Create Animated Skins from a SWF File
Recipe 9.18. Customize the Preloader
Chapter 10. Dragging and Dropping
Recipe 10.1. Use the DragManager Class
Recipe 10.2. Specify a Drag Proxy
Recipe 10.3. Drag and Drop Within a List
Recipe 10.4. Drag and Drop Between Lists
Recipe 10.5. Enable and Disable Drag Operations
Recipe 10.6. Customize the DragImage of a List-Based Control
Recipe 10.7. Customize the Drop Indicator of a List-Based Control
Chapter 11. States
Recipe 11.1. Set Styles and Properties in a State
Recipe 11.2. Create Transitions to Enter and Leave States
Recipe 11.3. Use the AddChildAction and RemoveChildAction
Recipe 11.4. Filter Transitions to Affect Only Certain Types of Children
Recipe 11.5. Apply Parts of a Transition to Certain Children
Recipe 11.6. Base a State on Another State
Recipe 11.7. Integrate View States with HistoryManagement
Recipe 11.8. Use Deferred Instance Factories with States
Recipe 11.9. Use Data Binding with Objects Added in a State
Recipe 11.10. Add and Remove Event Listeners in State Changes
Recipe 11.11. Add View States to a Flash Component
Recipe 11.12. Work with State Change Events
Recipe 11.13. Dynamically Generate and Use New States and Transitions
Recipe 11.14. Create Custom Actions to Use in a State
Chapter 12. Effects
Recipe 12.1. Call an Effect in MXML and in ActionScript
Recipe 12.2. Build a Custom Effect
Recipe 12.3. Create Parallel Series or Sequences of Effects
Recipe 12.4. Pause, Reverse, and Restart an Effect
Recipe 12.5. Create Custom Effect Triggers
Recipe 12.6. Create Tween Effects
Recipe 12.7. Use the DisplacementMapFilter Filter in a Flex Effect
Recipe 12.8. Create an AnimateColor Effect
Recipe 12.9. Use the Convolution Filter to Create a Tween
Chapter 13. Collections
Recipe 13.1. Add, Sort, and Retrieve Data from an ArrayCollection
Recipe 13.2. Filter an ArrayCollection
Recipe 13.3. Determine When an Item Is Modified in an ArrayCollection
Recipe 13.4. Create a GroupingCollection
Recipe 13.5. Create a Hierarchical Data Provider for a Control
Recipe 13.6. Navigate a Collection Object and Save Your Position
Recipe 13.7. Create a HierarchicalViewCollection Object
Recipe 13.8. Filter and Sort an XMLListCollection
Recipe 13.9. Sort on Multiple Fields in a Collection
Recipe 13.10. Sort on Dates in a Collection
Recipe 13.11. Create a Deep Copy of an ArrayCollection
Recipe 13.12. Use Data Objects with Unique IDs
Chapter 14. Data Binding
Recipe 14.1. Bind to a Property
Recipe 14.2. Bind to a Function
Recipe 14.3. Create a Bidirectional Binding
Recipe 14.4. Bind to Properties by Using ActionScript
Recipe 14.5. Use Bindable Property Chains
Recipe 14.6. Bind to Properties on XML by Using E4X
Recipe 14.7. Create Customized Bindable Properties
Recipe 14.8. Bind to a Generic Object
Recipe 14.9. Bind to Properties on a Dynamic Class
Chapter 15. Validation, Formatting, and Regular Expressions
Recipe 15.1. Use Validators and Formatters with TextInput and TextArea Controls
Recipe 15.2. Create a Custom Formatter
Recipe 15.3. Create a More-International Zip Code Validator by Using Regular Expressions
Recipe 15.4. Create a Validator to Validate UPCs
Recipe 15.5. Validate Combo Boxes and Groups of Radio Buttons
Recipe 15.6. Show Validation Errors by Using ToolTips in a Form
Recipe 15.7. Use Regular Expressions for Locating Email Addresses
Recipe 15.8. Use Regular Expressions for Matching Credit Card Numbers
Recipe 15.9. Use Regular Expressions for Validating ISBNs
Recipe 15.10. Create Regular Expressions by Using Explicit Character Classes
Recipe 15.11. Use Character Types in Regular Expressions
Recipe 15.12. Match Valid IP Addresses by Using Subexpressions
Recipe 15.13. Use Regular Expressions for Different Types of Matches
Recipe 15.14. Match Ends or Beginnings of Lines with Regular Expressions
Recipe 15.15. Use Back-References
Recipe 15.16. Use a Look-Ahead or Look-Behind
Chapter 16. Charting
Recipe 16.1. Create a Chart
Recipe 16.2. Add Effects to Charts
Recipe 16.3. Select Regions of a Chart
Recipe 16.4. Format Tick Marks for a Chart
Recipe 16.5. Create a Custom Label for a Chart
Recipe 16.6. Create a Drill-Down Effect for a Columnar Chart
Recipe 16.7. Skin Chart Items
Recipe 16.8. Use ActionScript to Dynamically Add and Remove Columns for a Chart
Recipe 16.9. Overlap Multiple ChartSeries
Recipe 16.10. Drag and Drop Items in a Chart
Recipe 16.11. Create an Editable Line Chart
Chapter 17. SharedObjects
Recipe 17.1. Create a SharedObject
Recipe 17.2. Write Data into a SharedObject
Recipe 17.3. Save a Local SharedObject
Recipe 17.4. Read Data from a SharedObject
Recipe 17.5. Remove Data from a SharedObject
Recipe 17.6. Serialize Typed Objects
Recipe 17.7. Access a SharedObject Between Multiple Flash Applications
Recipe 17.8. Remember TextInput Values for Returning Users
Chapter 18. Working with Services and Server-Side Communication
Recipe 18.1. Configure an HTTPService
Recipe 18.2. Use RESTful Communication Between Flex Applications
Recipe 18.3. Configure and Connect to a RemoteObject
Recipe 18.4. Use Flex Remoting with AMFPHP 1.9
Recipe 18.5. Use the IExternalizable Interface for Custom Serialization
Recipe 18.6. Track Results from Multiple Simultaneous Service Calls
Recipe 18.7. Use Publish/Subscribe Messaging
Recipe 18.8. Register a Server-Side Data Type Within a Flex Application
Recipe 18.9. Communicate with a WebService
Recipe 18.10. Add a SOAP Header to a Request to a WebService
Recipe 18.11. Parse a SOAP Response from a WebService
Recipe 18.12. Communicate Securely with AMF by Using SecureAMFChannel
Recipe 18.13. Send and Receive Binary Data via a Binary Socket
Recipe 18.14. Communicate Using an XMLSocket
Chapter 19. XML
Recipe 19.1. Load an XML File
Recipe 19.2. Navigate an XML Document in E4X
Recipe 19.3. Use Regular Expressions in E4X Queries
Recipe 19.4. Add an XMLList to an XML Object
Recipe 19.5. Bind to an XMLList or an E4X Query
Recipe 19.6. Generate XML Objects from Arrays
Recipe 19.7. Handle Namespaces in XML Returned by a Service
Recipe 19.8. Encode an ActionScript Data Object as XML
Recipe 19.9. Populate a Component with Complex XML Data
Recipe 19.10. Decode XML from a Web Service into Strongly Typed Objects
Chapter 20. Browser Communication
Recipe 20.1. Link to an External URL
Recipe 20.2. Work with FlashVars
Recipe 20.3. Invoke JavaScript Functions from Flex
Recipe 20.4. Invoke ActionScript Functions from JavaScript
Recipe 20.5. Change the HTML Page Title via BrowserManager
Recipe 20.6. Parse the URL via BrowserManager
Recipe 20.7. Deep-Link to Data via BrowserManager
Recipe 20.8. Deep-Link Containers via BrowserManager
Recipe 20.9. Implement Custom History Management
Chapter 21. Development Strategies
Recipe 21.1. Use the Flex Component Kit to Create Components
Recipe 21.2. Use the ContainerMovieClip to Create Flex Containers in Flash
Recipe 21.3. Import Components from Flash CS3
Recipe 21.4. Get Started with the Cairngorm Architecture
Recipe 21.5. Create a Cairngorm View, Event, and Model
Recipe 21.6. Create Cairngorm Commands and a Business Delegate Class
Recipe 21.7. Create a Cairngorm FrontController and a ServiceLocator
Recipe 21.8. Generate an Application Structure with the Cairngen Framework Generator
Recipe 21.9. Learn Common Performance-Tuning Tricks
Recipe 21.10. Create Custom Metadata Properties for a Component
Chapter 22. Modules and Runtime Shared Libraries
Recipe 22.1. Create a Runtime Shared Library
Recipe 22.2. Use Cross-Domain Runtime Shared Libraries
Recipe 22.3. Use the Flex Framework as a Runtime Shared Library
Recipe 22.4. Optimize a Runtime Shared Library
Recipe 22.5. Create an MXML-Based Module
Recipe 22.6. Create an ActionScript-Based Module
Recipe 22.7. Load a Module by Using ModuleLoader
Recipe 22.8. Use ModuleManager to Load Modules
Recipe 22.9. Load Modules from Different Servers
Recipe 22.10. Communicate with a Module
Recipe 22.11. Pass Data to Modules by Using Query Strings
Recipe 22.12. Optimize Modules by Using Linker Reports
Chapter 23. The Adobe Integrated Runtime API
Recipe 23.1. Create an AIR Application Leveraging the Flex Framework
Recipe 23.2. Understand the AIR Command-Line Tools
Recipe 23.3. Open and Manage Native Windows
Recipe 23.4. Create Native Menus
Recipe 23.5. Read and Write to a File
Recipe 23.6. Serialize Objects
Recipe 23.7. Use the Encrypted Local Store
Recipe 23.8. Browse for Files
Recipe 23.9. Use the AIR File System Controls
Recipe 23.10. Use the Native Drag-and-Drop API
Recipe 23.11. Interact with the Operating System Clipboard
Recipe 23.12. Add HTML Content
Recipe 23.13. Cross-Script Between ActionScript and JavaScript
Recipe 23.14. Work with Local SQL Databases
Recipe 23.15. Detect and Monitor a Network Connection
Recipe 23.16. Detect User Presence
Recipe 23.17. Create System Tray and Dock Applications
Chapter 24. Unit Testing with FlexUnit
Recipe 24.1. Create an Application That Uses the FlexUnit Framework
Recipe 24.2. Create an Application to Run FlexUnit Tests
Recipe 24.3. Create a FlexUnit Test Case
Recipe 24.4. Add a Test Case to a Test Suite
Recipe 24.5. Run Code Before and After Every Test
Recipe 24.6. Share Test Data Between Test Cases
Recipe 24.7. Handle Events in a Test Case
Recipe 24.8. Test Visual Components with FlexUnit
Recipe 24.9. Install and Configure Antennae
Recipe 24.10. Generate Automated Test Suites
Chapter 25. Compiling and Debugging
Recipe 25.1. Use Trace Statements Without Flex Builder
Recipe 25.2. Use the Component Compiler
Recipe 25.3. Install the Flex Ant Tasks
Recipe 25.4. Use the compc and mxmlc Tasks in the Flex Ant Tasks
Recipe 25.5. Compile and Deploy Flex Applications That Use RSLs
Recipe 25.6. Create and Monitor Expressions in Flex Builder Debugging
Recipe 25.7. Install the Ant View in the Stand-Alone Version of Flex Builder
Recipe 25.8. Create an Ant Build File for Automating Common Tasks
Recipe 25.9. Compile a Flex Application by Using mxmlc and Ant
Recipe 25.10. Generate Documentation by Using ASDoc and Ant
Recipe 25.11. Compile Flex Applications by Using Rake
Recipe 25.12. Use ExpressInstall for Your Application
Recipe 25.13. Use Memory Profiling with Flex Builder 3 to View Memory Snapshots
Chapter 26. Configuration, Internationalization, and Printing
Recipe 26.1. Add an International Character Set to an Application
Recipe 26.2. Use a Resource Bundle to Localize an Application
Recipe 26.3. Use the ResourceManager for Localization
Recipe 26.4. Use Resource Modules for Localization
Recipe 26.5. Support IME Devices
Recipe 26.6. Detect a Screen Reader
Recipe 26.7. Create a Tabbing Reading Order for Accessibility
Recipe 26.8. Print Selected Items in an Application
Recipe 26.9. Format Application Content for Printing
Recipe 26.10. Control Printing of Unknown Length Content over Multiple Pages
Recipe 26.11. Add a Header and a Footer When Printing
Index
Get Flex 3 Cookbook Code Recipes Tips and Tricks for RIA Developers 1st Edition Joshua Noble free all chapters
Copyright
Copyright © 2008, Joshua Noble and Todd Anderson. All rights reserved.
Printed in the United States of America.
Published by O'Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472.
O'Reilly books may be purchased for educational, business, or sales promotional use. Online editions are also
available for most titles (http://safari.oreilly.com). For more information, contact our corporate/institutional
sales department: (800) 998-9938 or corporate@oreilly.com.
Editor: Linda Laflamme
Production Editor: Michele Filshie
Editor: Sharon Wilkey
The O'Reilly logo is a registered trademark of O'Reilly Media, Inc. Flex 3 Cookbook, the image of the fringed
gecko, and related trade dress are trademarks of O'Reilly Media, Inc.
Many of the designations uses by manufacturers and sellers to distinguish their products are claimed as
trademarks. Where those designations appear in this book, and O'Reilly Media, Inc. was aware of a trademark
claim, the designations have been printed in caps or initial caps
While every precaution has been taken in the preparation of this book, the publisher and authors assume no
responsibility for errors or omissions, or for damages resulting from the use of the information contained herein.
Preface
Flex 3 is a powerful framework that provides enterprise-level components for the Flash Player platform in a
markup language format recognizable to anyone with HTML or XML development experience. The Flex
Framework provides components for visual layout, visual effects, data grids, server communication, charts, and
much more.
To put a blunt point on it, the Flex Framework is massive, and any book attempting to cover the entire
Framework in any depth will without question fail in some respect or another. With this in mind, we've made an
attempt to cover the topics that most vex developers working with Flex 3—in a way that can illuminate how the
Framework is structured as well as help solve common problems. The official Flex documentation is quite good
at explaining in depth how particular methods or classes behave, so instead we explain how to tackle common
tasks within the Flex Framework, how to get different components to work together, and how Flex can partner
with other technologies to create Rich Internet Applications and more. With the help of Adobe AIR, for example,
you can use the tools of Flex and the Flash Player to create deployable desktop applications. This complements
the expansion of open source and commercial tools for Java, .NET, and PHP development, among others,
making Flex a powerful solution for an ever wider range of development needs and challenges.
Recipe P.1. Bonus Chapters Online
The Flex framework is such a huge topic and we had so many recipes and so much information to cover that we
simply couldn't fit it all into the printed book. Four chapters totaling 76 pages are available to you online that
cover working with XML, the Charting components, working with SharedObjects, and Development Strategies
for creating Flex applications. Go to www.oreilly.com/catalog/9780596529857 to read this bonus material.
Recipe P.2. Who This Book Is For
Flex 3 Cookbook is for developers who want to understand the Flex Framework more thoroughly or who need a
reference to consult to solve particular problems. As such, this book assumes that you have some previous
experience with Flex and ActionScript 3. The code samples and explanations likewise are geared toward
intermediate developers familiar with the relationship between MXML and ActionScript, at least some of the
components that make up the Flex Framework, and basic strategies of Flex development.
We have made a very deliberate decision to ensure that all the recipes contain usable components and
functional, tested implementations of those components. This was not done with the intention of swelling the
book unreasonably, but to ensure that this book is suitable for intermediate and advanced developers who
simply need to see a small code snippet to understand a technique, as well as readers who are still learning how
the Flex Framework can be used and the best practices for working with it.
Recipe P.3. Who This Book Is Not For
If you need to learn the Flex Framework from scratch, consult Programming Flex 3 by Joey Lott and Chafic
Kazoun (O'Reilly, 2008) to gain an understanding of the core concepts of Flex development before reading any
further here. With a grounding in Flex and ActionScript basics, you'll be better prepared to take advantage of
the techniques in this book. If you need a refresher course in ActionScript development, try ActionScript 3.0
Cookbook by Joey Lott, Darron Schall, and Keith Peters (O'Reilly, 2006) for techniques focused on core Flash
ActionScript programming. Although Flex 3 Cookbook covers some areas of overlap between the Flex
Framework and core Flash ActionScript classes, this book is very much focused on Flex development.
Recipe P.4. How This Book Is Organized
As its name implies, Flex 3 Cookbook is stuffed full with recipes for techniques that will help you get more from
your Flex applications. To help you find the solutions you need faster, the recipes are organized by theme.
Generally the recipes progress from simpler topics to the more complex throughout each chapter.
This book was not intended to be read from cover to cover but rather to be used as a reference for a particular
problem, or to provide some insight into a particular aspect of the Flex Framework. The recipes also include
complete component implementations to show you how to completely implement the concept discussed. You
should be able to use the demonstrated code in your own applications or at the very minimum adapt relevant
portions of the code to your needs.
P.5. Conventions Used in This Book
The following typographical conventions are used in this book:
Italic
Indicates new terms, URLs, email addresses, filenames, and file extensions.
Constant width
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
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 or by values determined by context.
P.6. 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: "Flex 3 Cookbook by Joshua Noble and Todd Anderson. Copyright 2008 Joshua Noble and
Todd Anderson, 978-0-596-5298-57."
If you feel your use of code examples falls outside fair use or the permission given above, feel free to contact us
at permissions@oreilly.com.
P.7. How to Use This Book
Think of this book like a friend and a counselor. Don't put it on a shelf. Keep it on your desk where you can
consult it often. When you are uncertain as to how something works or how to approach a specific programming
issue pick up the book and flip to the relevant recipe(s). We have written this book in a format so that you can
get answers to specific questions quickly. And since it's a book you don't ever have to worry that it will laugh at
you for asking questions. No question is too big or too small.
Although you can read the book from cover to cover, we encourage you to use this book when you need an
answer. Rather than teaching you a bunch of theory, this book intends to help you solve problems and
accomplish tasks. This book is meant for field work, not the research lab.
P.8. O'Reilly Cookbooks
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:
Problem
Each Problem addressed in an O'Reilly Cookbook is clearly stated, specific, and practical.
Solution
The Solution is easy to understand and implement.
Discussion
The Discussion clarifies and explains the context of the Problem and the Solution. It also contains sample
code to show you how to get the job done. Best of all, all of the sample code you see in an O'Reilly
Cookbook can be downloaded from the book's web site, at http://www.oreilly.com/catalog/actscpt3ckbk.
See Also
The See Also section directs you to additional information related to the topic covered in the recipe. You'll
find pointers to other recipes in the book, to other books (including non-O'Reilly titles), web sites, and
more.
To learn more about the O'Reilly Cookbook series, or to find other Cookbooks that are up your alley, visit their
web site at http://cookbooks.oreilly.com.
P.9. Safari® Enabled
NOTE
When you see a Safari® Enabled 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.
P.10. How to Contact Us
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/9780596529857
To comment or ask technical questions about this book, send email to:
bookquestions@oreilly.com
For more information about our books, conferences, Resource Centers, and the O'Reilly Network, see our web
site at:
http://www.oreilly.com
Recipe P.11. Acknowledgments
This book truly does represent a product of the Flex community. Thanks belong to many developers and the
community relations managers at Adobe, Amy Wong, Matt Chotin, Ely Greenfield, and Alex Harui in particular,
as well as to the developers who work with Adobe products and contributed to the Flex Cookbook site or
blogged about what they discovered. Without all of them, this book would not be conceivable.
Many, many thanks are due to the many people at O'Reilly who made this book possible. Many special thanks
go to Steve Weiss, Linda Laflamme, and Michele Filshie for their hard work, flexibility, and patience throughout
the writing and editing of this book.
The quality of the technical information within this book is not simply due to the knowledge of the many authors
of this book. The technical reviewers for this book, Mark Walters (http://www.digitalflipbook.com/), Alfio
Raymond, and Jen Blackledge, not only provided help debugging, correcting, and clarifying the code for this
book, but also provided fantastic insight into ways to clarify explanations, structure chapters, alter recipes, and
help the readers' understanding.
Recipe P.11.1. From Joshua
First and foremost, I need to thank Joey Lott for so graciously helping me get the opportunity to write this book
and the one before this. I wouldn't be writing this without his encouragement and advocacy for my abilities, and
I can't thank him enough for believing in me enough to recommend me for this book. The same goes to Steve
Weiss, who took a chance on a somewhat unknown author and made it possible for the book to blossom to its
current size. To my co-authors, Todd Anderson and Abey George, and also the people at Cynergy Systems,
Andrew Trice, Craig Drabnik, Keun Lee, and Ryan Miller, for stepping in and helping when I needed them, to all
of them I owe a huge debt. I also need to thank Daniel Rinehart, who did such a fantastic job writing the recipes
that make up "Unit Testing with FlexUnit," simply to educate and share with the Flex community, completely
unprompted. The same goes for everyone who participated in the Adobe Cookbook site and on forums like
FlexCoders, making a vibrant, helpful community that helps us all.
I'd also like to thank my friends whom I've known from jobs and from life, for providing me with so much help,
advice, support, and humor. Finally, I'd like to thank my family, and in particular my mother, for always
providing me with encouragement and wisdom.
Recipe P.11.2. From Todd
I would first like to thank Josh Noble for asking me to participate in this book and for providing knowledge,
patience, and humor throughout. I'd also like to thank Joey Lott for his huge encouragement and belief in
people's abilities. I'd like to thank my friends and the Flash community for offering advice, a few laughs, and
expertise. And finally to my family, I cannot thank you enough for the huge love and support.
Recipe P.12. Author Bios
Joshua Noble, a development consultant based in New York City, is the co-author of ActionScript 3.0 Bible
(Wiley, 2007). He has worked with Flex and Flash on a wide range of web applications on a variety of platforms
over the past six years as well as working with PHP, Ruby, Erlang, and C#. In his free time, he enjoys playing
with C++ and OpenCV as well as using microcontrollers and sensors to create reactive environments. His
website is http://thefactoryfactory.com.
Todd Anderson is a senior software engineer for Infrared5. With over five years of developing for the Flash
platform in the areas of RIA and game development, Todd has delivered web and desktop solutions for the
publishing and entertainment industries with companies including McGraw-Hill, Thomson, Motorola, and Condé
Nast Publications. Currently residing in the Boston area, when he's not programming he likes to get back to his
fine arts roots and build things on paper. Anderson runs www.custardbelly.com/blog, focusing on development
of the Flash platform.
P.13. Contributor Bios
Abey George is a software engineer with expertise in architecting and developing Rich Internet Applications
(RIAs). He has implemented a wide range of RIA solutions for both web and enterprise applications by using a
combination of Flex, Flash, and C#. He holds an MS from Texas A&M University and has over six years of
professional experience in the field of software engineering. Interested in effectively leveraging RIAs in the
enterprise, Abey is currently a principal software engineer at Fidelity Investments and has worked previously for
Yahoo, Keane, and Mindseye.
Daniel Rinehart is a software architect at Allurent, where he is helping to build a new generation of innovative
online shopping experiences using Flex. He has worked in the field of software development as an engineer and
architect for the past eight years. Prior to joining Allurent, Daniel worked at Ruckus Network, Towers Perrin, and
Bit Group, where his clients included Cisco and Dell Financial Services. He can be reached on the Web at
http://danielr.neophi.com/.
Andrew Trice is the principal architect for Flex and AIR for Cynergy Systems. He specializes in data
visualization, client-server architectures, object-oriented principles, and rich application development. He has
been developing for the Web for over 10 years, with over eight years of development for the Flash platform.
Thriving on the creativity and flexibility that the Flex/Flash platform enable, Andrew has developed with Flex
since version 1.5. Andrew also possesses over seven years' experience with ColdFusion, is a Microsoft Certified
Application Developer, and has a wide range of knowledge regarding relational databases, Ajax/JavaScript,
.NET, and Java web applications.
Keun Lee is a technical lead for Cynergy Systems. He specializes in technologies such as Adobe Flex and the
Microsoft Windows Presentation Foundation. He has an extensive background in business intelligence, B2B
application architecture, and Rich Internet Application development. In his spare time, he enjoys playing and
composing music and in general building cool things with the abundance of available technology at his disposal.
Craig Drabik has been building web applications since 2000 by using DHTML, ColdFusion, Flash, and Flex. He
currently works for Cynergy Systems, leading the implementation of customer Flex projects.
Ryan Taylor is an award-winning artist and programmer specializing in object-oriented Flash development and
static/motion design. He currently serves as a senior developer on the Multimedia Platforms Group at
Schematic. Ryan frequently speaks at industry events and shares all of his thoughts, experiments, and open
source contributions on his blog at www.boostworthy.com/blog.
Marco Casario founded Comtaste (www.comtaste.com), a company dedicated to exploring new frontiers in
Rich Internet Applications and the convergence of the Web and the world of mobile devices. He is the author of
the Flex Solutions: Essential Techniques for Flex 2 and Flex 3 Developers (Friends of ED, 2007) and Advanced
AIR Applications (Friends of ED, 2008). Marco often speaks at such conferences as Adobe MAX, O'Reilly Web 2.0
Summit, FITC, AJAXWorld Conference & Expo, 360Flex, From A to Web, AdobeLive, and many others, details of
which are on his blog at http://casario.blogs.com.
Andrei Ionescu is a Romanian web developer who likes new technologies and making them interact. He enjoys
making and implementing Rich Internet Applications in the best possible way and bringing to life all kinds of
web applications. He is author of the Flex blog www.flexer.info, and his company site is www.designit.ro.
Ryan Miller has been developing web applications for more than seven years. Working for companies big and
small, he's managed to get his hands all kinds of dirty over the years. Currently he works out of his Beaverton,
Oregon home for Cynergy Systems doing Flex development, all day, every day, and loving every minute.
P.14. Colophon
The animal on the cover is a fringed gecko.
The cover image is from Wood's Animate Creation. The cover font is Adobe ITC Garamond. The text font is
Linotype Birka; the heading font is Adobe Myriad Condensed; and the code font is LucasFont's
TheSansMomoCondensed.
Chapter 1. Flex and ActionScript Basics
A Flex application consists primarily of code written in two different languages: ActionScript and MXML. Now in
its 3.0 incarnation, ActionScript has gone from a prototype-based scripting language to a fully object-oriented,
strictly typed, ECMAScript language. MXML is a markup language that will feel comfortable immediately to
anyone who has spent time working with Hypertext Markup Language (HTML), Extensible Markup Language
(XML), or a host of newer markup-based languages.
How do MXML and ActionScript relate to one another? The compiler, after parsing through the different idioms,
translates them into the same objects, so that
<mx:Button id="btn" label="My Button" height="100"/>
and
var btn:Button = new Button();
btn.label = "My Button";
btn.height = 100;
produce the same object. The major difference is that whereas creating that object in ActionScript (second
example) creates the button and nothing else, creating the object in MXML adds the button to whatever
component contains the MXML code. The Flex Framework handles calling the constructor of the object described
in MXML and either adding it to the parent or setting it as a property of a parent.
MXML files can include ActionScript within an <mx:Script> tag, but ActionScript files cannot include MXML.
Although it's tempting to think of MXML as the description of the appearance and components that make up
your application, and of ActionScript as the description of the event handlers and custom logic your application
requires, this is not always true. A far better way to think of their relationship is to understand that both
languages ultimately describe the same objects via different syntax. Certain aspects of the Flash platform
cannot be accessed without using ActionScript for loops, function declarations, and conditional statements,
among many others. This is why the use of ActionScript and the integration between MXML and ActionScript is
necessary for all but the very simplest applications.
This chapter discusses many aspects of integrating MXML and ActionScript: creating components in MXML,
creating classes in ActionScript, adding event listeners, creating code-behind files by using ActionScript and
MXML, and creating function declarations. Although it doesn't contain all the answers, it will get you started with
the basics of ActionScript and MXML.
Recipe 1.1. Create a Flex Project in Flex Builder
Recipe 1.1.1. Problem
You want to create a project in Flex Builder.
Recipe 1.1.2. Solution
Use the Create New Project wizard.
Recipe 1.1.3. Discussion
Flex Builder is built on top of Eclipse, the venerable and well-respected integrated development environment
(IDE) most strongly associated with Java development. Although Flex Builder certainly is not necessary for Flex
development, it is the premier tool for creating Flex applications and as such provides a wealth of features to
help you design and develop applications more effectively. You can use Flex Builder either as a stand-alone
application or as a plug-in to an existing installation of Eclipse.
The first thing you need to do as a Flex developer is to create a Flex project. A Flex project is different from the
other types of projects in Flex Builder because it includes theSWC (Flex library) Flex library SWC (unlike an
ActionScript project) and is compiled to a SWF file that can be viewed in the Flash Player (unlike a Flex Library
project). To create a project, right-click or Control-click (Mac) in Flex Builder's project navigator to display the
contextual menu (Figure 1-1), or use the File menu at the top of the application. From either, choose New
Flex Project. A dialog box appears to guide you through creating a project.
Figure 1-1. Creating a new Flex project
When prompted to specify how the project will get its data, choose Basic, which brings you to the New Flex
Project dialog box (Figure 1-2).
Figure 1-2. Creating a new project in Flex Builder
Enter an application name and below, a location where the files will be stored on your system. The default
location is C:/Documents and Settings/Username/Documents/workspace/Projectname on a Windows machine,
and Users/Username/Documents/workspace/Projectname on a Mac. You can of course, uncheck Use Default
Location and store your files wherever you like. The name of the project must be unique. The Application Type
section lets you select whether you are making an Adobe Integrated Runtime (AIR) application or an application
that will run in a browser via the Flash Player plug-in. Finally, the Server Technology settings let you indicate
whether the application will be connecting to a server, and if so, what server type and separate configuration
type are needed.
If you have nothing more to add, click Finish. To change the location where the compiled SWF file will be placed,
click Next to reach the screen shown in Figure 1-3.
Figure 1-3. Setting the location where the compiled SWF will be placed
After the location of the generated SWF has been set, you can either finish or add source folders or SWC files to
the project. To add another folder or set of folders, click the Source Path tab (Figure 1-4). To add SWC files to
the project, click the Library Path tab (Figure 1-5). On this screen, you can also change the main MXML
application file, which is by default the same name as the project.
Figure 1-4. Setting the source folder and main application file
Figure 1-5. Setting any additional libraries for a Flex project
With all paths and names specified, click Finish. Your project is now configured, and you are ready to begin
development.
Chapter 1. Flex and ActionScript Basics
A Flex application consists primarily of code written in two different languages: ActionScript and MXML. Now in
its 3.0 incarnation, ActionScript has gone from a prototype-based scripting language to a fully object-oriented,
strictly typed, ECMAScript language. MXML is a markup language that will feel comfortable immediately to
anyone who has spent time working with Hypertext Markup Language (HTML), Extensible Markup Language
(XML), or a host of newer markup-based languages.
How do MXML and ActionScript relate to one another? The compiler, after parsing through the different idioms,
translates them into the same objects, so that
<mx:Button id="btn" label="My Button" height="100"/>
and
var btn:Button = new Button();
btn.label = "My Button";
btn.height = 100;
produce the same object. The major difference is that whereas creating that object in ActionScript (second
example) creates the button and nothing else, creating the object in MXML adds the button to whatever
component contains the MXML code. The Flex Framework handles calling the constructor of the object described
in MXML and either adding it to the parent or setting it as a property of a parent.
MXML files can include ActionScript within an <mx:Script> tag, but ActionScript files cannot include MXML.
Although it's tempting to think of MXML as the description of the appearance and components that make up
your application, and of ActionScript as the description of the event handlers and custom logic your application
requires, this is not always true. A far better way to think of their relationship is to understand that both
languages ultimately describe the same objects via different syntax. Certain aspects of the Flash platform
cannot be accessed without using ActionScript for loops, function declarations, and conditional statements,
among many others. This is why the use of ActionScript and the integration between MXML and ActionScript is
necessary for all but the very simplest applications.
This chapter discusses many aspects of integrating MXML and ActionScript: creating components in MXML,
creating classes in ActionScript, adding event listeners, creating code-behind files by using ActionScript and
MXML, and creating function declarations. Although it doesn't contain all the answers, it will get you started with
the basics of ActionScript and MXML.
Recipe 1.1. Create a Flex Project in Flex Builder
Recipe 1.1.1. Problem
You want to create a project in Flex Builder.
Recipe 1.1.2. Solution
Use the Create New Project wizard.
Recipe 1.1.3. Discussion
Flex Builder is built on top of Eclipse, the venerable and well-respected integrated development environment
(IDE) most strongly associated with Java development. Although Flex Builder certainly is not necessary for Flex
development, it is the premier tool for creating Flex applications and as such provides a wealth of features to
help you design and develop applications more effectively. You can use Flex Builder either as a stand-alone
application or as a plug-in to an existing installation of Eclipse.
The first thing you need to do as a Flex developer is to create a Flex project. A Flex project is different from the
other types of projects in Flex Builder because it includes theSWC (Flex library) Flex library SWC (unlike an
ActionScript project) and is compiled to a SWF file that can be viewed in the Flash Player (unlike a Flex Library
project). To create a project, right-click or Control-click (Mac) in Flex Builder's project navigator to display the
contextual menu (Figure 1-1), or use the File menu at the top of the application. From either, choose New
Flex Project. A dialog box appears to guide you through creating a project.
Figure 1-1. Creating a new Flex project
When prompted to specify how the project will get its data, choose Basic, which brings you to the New Flex
Project dialog box (Figure 1-2).
Figure 1-2. Creating a new project in Flex Builder
Enter an application name and below, a location where the files will be stored on your system. The default
location is C:/Documents and Settings/Username/Documents/workspace/Projectname on a Windows machine,
and Users/Username/Documents/workspace/Projectname on a Mac. You can of course, uncheck Use Default
Location and store your files wherever you like. The name of the project must be unique. The Application Type
section lets you select whether you are making an Adobe Integrated Runtime (AIR) application or an application
that will run in a browser via the Flash Player plug-in. Finally, the Server Technology settings let you indicate
whether the application will be connecting to a server, and if so, what server type and separate configuration
type are needed.
If you have nothing more to add, click Finish. To change the location where the compiled SWF file will be placed,
click Next to reach the screen shown in Figure 1-3.
Figure 1-3. Setting the location where the compiled SWF will be placed
After the location of the generated SWF has been set, you can either finish or add source folders or SWC files to
the project. To add another folder or set of folders, click the Source Path tab (Figure 1-4). To add SWC files to
the project, click the Library Path tab (Figure 1-5). On this screen, you can also change the main MXML
application file, which is by default the same name as the project.
Figure 1-4. Setting the source folder and main application file
Figure 1-5. Setting any additional libraries for a Flex project
With all paths and names specified, click Finish. Your project is now configured, and you are ready to begin
development.
Recipe 1.2. Create a Flex Library Project in Flex Builder
Recipe 1.2.1. Problem
You need to create a Flex Library project.
Recipe 1.2.2. Solution
From the Flex Navigator, choose New Flex Library Project to access the Create New Project wizard.
Recipe 1.2.3. Discussion
A Flex Library project does not have a main MXML file that it is compiled into a SWF. Instead the files are
compiled into a SWC file that can be used in other applications or as the source for a runtime shared library
(usually referred to as an RSL). The classes within the library are used to create a group of assets that can be
reused in multiple projects at either compile time or runtime. To create a Flex Library project, right-click or
Control-click (Mac) in the Flex Builder's project navigator to open the contextual menu (Figure 1-6) or use the
File menu. In either case, then choose New Flex Library Project.
Figure 1-6. Creating a Flex Library project
In the resulting dialog box (Figure 1-7), specify a name for your project as well as its location.
Figure 1-7. Setting the project location and SDK for the compiler
If you have nothing more to add, click Finish now. If you need to include files, assets, or other SWC files,
including the Adobe AIR libraries, click Next and select them from the resulting screen. To set classes that can
be selected and added into the recipe, first browse to a source path you would like to include and then set
either classes or graphical assets that will be compiled into the library. Click Finish to create the project.
Recipe 1.3. Create an ActionScript Project
Recipe 1.3.1. Problem
You want to create an ActionScript project that does not use the Flex 3 libraries.
Recipe 1.3.2. Solution
Use the Create New Project wizard and select ActionScript Project.
Recipe 1.3.3. Discussion
An ActionScript project is different from a Flex project in that it does not include the Flex Framework at all.
ActionScript projects rely on the core ActionScript classes within the Flash code base and do not have access to
any of the components in the Flex Framework. To create an ActionScript project, choose File New
ActionScript Project (Figure 1-8).
Figure 1-8. Creating an ActionScript project
In the resulting dialog box, specify a name for the project and a location where the files and compiled SWFs will
reside. Click Finish to finalize the project with default settings, or click Next to add libraries or other source
folders to the project, change the main file of the application, add SWC files that your code can access, or
change the location of the output SWF. By default, the name of the main ActionScript file for the application will
be set as the name of the project. The default output location of the SWF file will be the bin-debug folder in the
project.
Recipe 1.4. Set Compiler Options for the MXML Compiler in Flex Builder
Recipe 1.4.1. Problem
You need to set specific compiler options for the MXML compiler.
Recipe 1.4.2. Solution
Set the options for the compiler arguments in the Flex Compiler screen of the Project Properties dialog box.
Recipe 1.4.3. Discussion
The MXML compiler, also called the mxmlc, is the application that compiles ActionScript and MXML files into a
SWF file that can be viewed in the Flash Player. When you run or debug a Flex application in Flex Builder, the
MXML compiler is invoked and the files are passed to the compiler as an argument to the application. When you
debug the player, an argument to create a debug SWF is passed to the MXML compiler. Flex Builder lets you
pass other arguments to the MXML compiler, as well; for example, you can pass arguments to specify the
location of an external library path, allow the SWF to access local files, or set the color of the background.
To change the compiler settings for a project, right-click or Control-click (Mac) on the project and select
Properties from the contextual menu (Figure 1-9), or choose Project Properties from the menu bar.
Figure 1-9. Changing the properties of a project
In the resulting Project Properties dialog box (Figure 1-10), select Flex Compiler. Here you have several options
to control how the SWF file is compiled. In the input field labeled Additional Compiler Arguments, you can add
multiple options; simply type a hyphen (-) in front of each option and separate the options with spaces.
Figure 1-10. Setting compiler options
Some of the most commonly used options are as follows:
verbose-stacktraces
Specifies whether the SWF will include line numbers and filenames when a runtime error occurs. This
makes the generated SWF larger, and a SWF with verbose-stacktraces is different than a debug SWF.
source-path path-element
Adds any directories or files to the source path to have any MXML or ActionScript files be included. You
can use wildcards to include all files and subdirectories of a directory. Also you can use += to append the
new argument to the default options or any options set in a configuration file, for example:
-source-path+=/Users/base/Project
include-libraries
Specifies a SWC file to be compiled into the application and links all the classes and assets in the library
into the SWF. This option is useful if the application will load in other modules that may need access to
the classes in a SWC that the SWF will not be using.
library-path
Similar to the include-libraries option but includes only classes and assets that are used in the SWF.
This lets you keep the size of the SWF file manageable.
locale
Specifies a locale to be associated with a SWF file. For example, use -locale=es_ES to specify that the
SWF is localized for Spanish.
use-network
Indicates whether the SWF will have access to the local file system and is intended for use on a local
machine, or whether the standard Flash Player security will apply. For example, use -use-network=false
to specify that the SWF will have local file system access but will not be able to use any network services.
The default value is true.
frames.frame
Enables you to add asset factories that stream in after the application and then publish their interfaces
with the ModuleManager class. The advantage of doing this is that the application starts faster than it
would have if the assets had been included in the code, but does not require moving the assets to an
external SWF file. One of the more difficult and more useful parameters.
keep-all-type-selectors
Ensures that all style information, even if it is not used in the application, is compiled into the SWF. This
is important if the application will be loading other components that require style information. The default
value is false, which means that style information not used in the application is not compiled into the
SWF.
After setting the options for the compiler, click the Apply button to save the options for that project.
Recipe 1.5. Compile a Flex Project Outside of Flex Builder
Recipe 1.5.1. Problem
You are not using Flex Builder for your Flex project and need to compile your project.
Recipe 1.5.2. Solution
Use a terminal or command prompt to invoke the MXML compiler.
Recipe 1.5.3. Discussion
Although Flex Builder is a powerful tool for Flex development, it is certainly not necessary for creating Flex
applications. The MXML compiler (mxmlc) is free to anyone and can be downloaded from Adobe. To compile a
Flex application outside of Flex Builder, open a command prompt (Windows) or a terminal (Mac OS X), invoke
the MXML compiler, and pass the file containing the application as an argument, using a command such as the
following:
Code View:
home:base$ . /Users/base/Flex SDK 3/bin/mxmlc ~/Documents/FlexTest/FlexTest.mxml
This will compile the MXML file into a SWF that by default compiles into the folder where the MXML file is
located. Any warnings or errors from the compiler will be displayed in the terminal or command-prompt window.
To add further options to the MXML compiler, you append arguments to the call to the compiler. For example:
Code View:
home:base$ ./mxmlc ~/Documents/FlexTest/FlexTest.mxml -output=/Users/base/test/genera
ted/Index.swf -library-path+=/Users/lib/MyLib.swc
generates a SWF file named Index.swf, places it in the directory at /Users/base/test/generated/, and includes
the SWC library /Users/lib/MyLib.swc.
To invoke the MXML compiler directly from the command line without providing the full path to your SDK
installation (which in this example is C:flex_sdk_3), you will need to add the /bin directory the compiler resides
in to the Path systems variable.
On Windows:
Open System from the Control Panel.
1.
Select the Advanced tab.
2.
3.
2.
Click Environment Variables.
3.
Within the System variables grid, navigate to and double-click Path.
4.
In the Variable Value field, if the last character is not set to a semicolon (;), enter a
semicolon and then the path to the /bin folder within your Flex SDK installation directory
(Figure 1-11).
Figure 1-11. Setting the Flex SDK 3 Path variable
5.
6.
With the path to the MXML compiler directory set, open a command prompt, navigate to your
project directory, and enter the following command:
C:DocumentsFlexTest> mxmlc FlexTest.mxml
This generates the FlexTest.swf file within C:DocumentsFlexTest, just as the first command
presented in this section does. Setting the path to the /bin directory of the Flex 3 SDK
installation lets you invoke the compiler from any directory including, in this example, your
current project directory.
6.
If step 6 results in the following error message
Error: could not find JVM
you must manually enter the path to the directory in which the Java Runtime Environment
(JRE) is installed on your machine. To manually enter the path, navigate to the /bin directory
of your Flex 3 SDK installation. Open the jvm.config file in a text editor, and append the path
to your JRE installation directory to the variable java.home. Assuming the Java installation is
on the root of your drive, you enter the following:
java.home=C:/Java/jre
7.
On Mac OS X or Linux:
Open your .bash_profile file (if you are using Bash) and edit the path variable by adding the
location of the MXML compiler. Your .bash_profile file should look something like this:
PATH="${PATH}:~/flex3SDK/bin"
export PATH
The .bash_profile will be located in your user home directory (which you can always access
via a command line by typing cd ~). If you are using tsch, the path to the MXML compiler
should be added to the .profile file.
1.
If the Java runtime is not set properly, set the following path variable in your terminal shell:
PATH="${PATH}:~/flex3SDK/bin"
export PATH
2.
Exploring the Variety of Random
Documents with Different Content
Gutenberg™’s goals and ensuring that the Project Gutenberg™
collection will remain freely available for generations to come. In
2001, the Project Gutenberg Literary Archive Foundation was
created to provide a secure and permanent future for Project
Gutenberg™ and future generations. To learn more about the
Project Gutenberg Literary Archive Foundation and how your
efforts and donations can help, see Sections 3 and 4 and the
Foundation information page at www.gutenberg.org.
Section 3. Information about the Project
Gutenberg Literary Archive Foundation
The Project Gutenberg Literary Archive Foundation is a non-
profit 501(c)(3) educational corporation organized under the
laws of the state of Mississippi and granted tax exempt status by
the Internal Revenue Service. The Foundation’s EIN or federal
tax identification number is 64-6221541. Contributions to the
Project Gutenberg Literary Archive Foundation are tax
deductible to the full extent permitted by U.S. federal laws and
your state’s laws.
The Foundation’s business office is located at 809 North 1500
West, Salt Lake City, UT 84116, (801) 596-1887. Email contact
links and up to date contact information can be found at the
Foundation’s website and official page at
www.gutenberg.org/contact
Section 4. Information about Donations to
the Project Gutenberg Literary Archive
Foundation
Project Gutenberg™ depends upon and cannot survive without
widespread public support and donations to carry out its mission
of increasing the number of public domain and licensed works
that can be freely distributed in machine-readable form
accessible by the widest array of equipment including outdated
equipment. Many small donations ($1 to $5,000) are particularly
important to maintaining tax exempt status with the IRS.
The Foundation is committed to complying with the laws
regulating charities and charitable donations in all 50 states of
the United States. Compliance requirements are not uniform
and it takes a considerable effort, much paperwork and many
fees to meet and keep up with these requirements. We do not
solicit donations in locations where we have not received written
confirmation of compliance. To SEND DONATIONS or
determine the status of compliance for any particular state visit
www.gutenberg.org/donate.
While we cannot and do not solicit contributions from states
where we have not met the solicitation requirements, we know
of no prohibition against accepting unsolicited donations from
donors in such states who approach us with offers to donate.
International donations are gratefully accepted, but we cannot
make any statements concerning tax treatment of donations
received from outside the United States. U.S. laws alone swamp
our small staff.
Please check the Project Gutenberg web pages for current
donation methods and addresses. Donations are accepted in a
number of other ways including checks, online payments and
credit card donations. To donate, please visit:
www.gutenberg.org/donate.
Section 5. General Information About Project
Gutenberg™ electronic works
Professor Michael S. Hart was the originator of the Project
Gutenberg™ concept of a library of electronic works that could
be freely shared with anyone. For forty years, he produced and
distributed Project Gutenberg™ eBooks with only a loose
network of volunteer support.
Project Gutenberg™ eBooks are often created from several
printed editions, all of which are confirmed as not protected by
copyright in the U.S. unless a copyright notice is included. Thus,
we do not necessarily keep eBooks in compliance with any
particular paper edition.
Most people start at our website which has the main PG search
facility: www.gutenberg.org.
This website includes information about Project Gutenberg™,
including how to make donations to the Project Gutenberg
Literary Archive Foundation, how to help produce our new
eBooks, and how to subscribe to our email newsletter to hear
about new eBooks.
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
Let us accompany you on the journey of exploring knowledge and
personal growth!
ebookfinal.com

More Related Content

PDF
Flex 3 Cookbook Code Recipes Tips and Tricks for RIA Developers 1st Edition J...
PDF
PDF Flex 3 Cookbook Code Recipes Tips and Tricks for RIA Developers 1st Editi...
PDF
Flex 3 Cookbook Code Recipes Tips and Tricks for RIA Developers 1st Edition J...
PPTX
Introduction to TinyMCE Session #5 Popular Plugins
PDF
Learning Cocoa with Objective C 2nd Edition James Duncan Davidson
PDF
Java How To Program Early Objects Eleventh Edition Deitel Harvey M Deitel
DOCX
PDF
Immediate download New Perspectives on HTML5 CSS3 JavaScript 6th Edition Care...
Flex 3 Cookbook Code Recipes Tips and Tricks for RIA Developers 1st Edition J...
PDF Flex 3 Cookbook Code Recipes Tips and Tricks for RIA Developers 1st Editi...
Flex 3 Cookbook Code Recipes Tips and Tricks for RIA Developers 1st Edition J...
Introduction to TinyMCE Session #5 Popular Plugins
Learning Cocoa with Objective C 2nd Edition James Duncan Davidson
Java How To Program Early Objects Eleventh Edition Deitel Harvey M Deitel
Immediate download New Perspectives on HTML5 CSS3 JavaScript 6th Edition Care...

Similar to Get Flex 3 Cookbook Code Recipes Tips and Tricks for RIA Developers 1st Edition Joshua Noble free all chapters (20)

PDF
New Perspectives on HTML5 CSS3 JavaScript 6th Edition Carey Solutions Manual
PPT
Daniel Egan Msdn Tech Days Oc Day2
PDF
Download full ebook of p instant download pdf
PDF
New Perspectives on HTML5 CSS3 JavaScript 6th Edition Carey Solutions Manual
PDF
Microsoft Office Xp Developers Guide Prodeveloper Microsoft Corporation
PDF
Advanced Programming Using Visual Basic 2008 4th Edition Julia Case Bradley
PDF
(Ebook) C# 6 and .NET Core 1.0: Modern Cross-Platform Development by Mark J. ...
PDF
Learning Cocoa with Objective C 2nd Edition James Duncan Davidson
PDF
Entity Framework Core Cookbook 2nd Edition Ricardo Peres
PDF
New Perspectives on HTML5 CSS3 JavaScript 6th Edition Carey Solutions Manual
PDF
Programming Microsoft SQL Server 2000 with Microsoft Visual Basic NET 1st edi...
PDF
Programming Microsoft SQL Server 2000 with Microsoft Visual Basic NET 1st edi...
PDF
New Perspectives on HTML5 CSS3 JavaScript 6th Edition Carey Solutions Manual
PPT
2 Day - WPF Training by Adil Mughal
PDF
New Perspectives on HTML5 CSS3 JavaScript 6th Edition Carey Solutions Manual
PDF
Immediate access to Microsoft ASP NET coding strategies with the Microsoft AS...
PDF
New Perspectives on HTML5 CSS3 JavaScript 6th Edition Carey Solutions Manual
PDF
Programming Microsoft SQL Server 2000 with Microsoft Visual Basic NET 1st edi...
PPTX
UNIT - 1 VISUAL BASIC PRESENTATION FOR IT
PDF
Cocoa Programming For Mac Os X 4th Edition Aaron Hillegass Adam Preble
New Perspectives on HTML5 CSS3 JavaScript 6th Edition Carey Solutions Manual
Daniel Egan Msdn Tech Days Oc Day2
Download full ebook of p instant download pdf
New Perspectives on HTML5 CSS3 JavaScript 6th Edition Carey Solutions Manual
Microsoft Office Xp Developers Guide Prodeveloper Microsoft Corporation
Advanced Programming Using Visual Basic 2008 4th Edition Julia Case Bradley
(Ebook) C# 6 and .NET Core 1.0: Modern Cross-Platform Development by Mark J. ...
Learning Cocoa with Objective C 2nd Edition James Duncan Davidson
Entity Framework Core Cookbook 2nd Edition Ricardo Peres
New Perspectives on HTML5 CSS3 JavaScript 6th Edition Carey Solutions Manual
Programming Microsoft SQL Server 2000 with Microsoft Visual Basic NET 1st edi...
Programming Microsoft SQL Server 2000 with Microsoft Visual Basic NET 1st edi...
New Perspectives on HTML5 CSS3 JavaScript 6th Edition Carey Solutions Manual
2 Day - WPF Training by Adil Mughal
New Perspectives on HTML5 CSS3 JavaScript 6th Edition Carey Solutions Manual
Immediate access to Microsoft ASP NET coding strategies with the Microsoft AS...
New Perspectives on HTML5 CSS3 JavaScript 6th Edition Carey Solutions Manual
Programming Microsoft SQL Server 2000 with Microsoft Visual Basic NET 1st edi...
UNIT - 1 VISUAL BASIC PRESENTATION FOR IT
Cocoa Programming For Mac Os X 4th Edition Aaron Hillegass Adam Preble
Ad

Recently uploaded (20)

PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PPTX
GDM (1) (1).pptx small presentation for students
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
Insiders guide to clinical Medicine.pdf
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
Computing-Curriculum for Schools in Ghana
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PPTX
Lesson notes of climatology university.
PDF
Basic Mud Logging Guide for educational purpose
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PPTX
PPH.pptx obstetrics and gynecology in nursing
PDF
01-Introduction-to-Information-Management.pdf
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
2.FourierTransform-ShortQuestionswithAnswers.pdf
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
GDM (1) (1).pptx small presentation for students
O5-L3 Freight Transport Ops (International) V1.pdf
Insiders guide to clinical Medicine.pdf
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Computing-Curriculum for Schools in Ghana
Abdominal Access Techniques with Prof. Dr. R K Mishra
Lesson notes of climatology university.
Basic Mud Logging Guide for educational purpose
102 student loan defaulters named and shamed – Is someone you know on the list?
Microbial disease of the cardiovascular and lymphatic systems
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
Module 4: Burden of Disease Tutorial Slides S2 2025
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Microbial diseases, their pathogenesis and prophylaxis
PPH.pptx obstetrics and gynecology in nursing
01-Introduction-to-Information-Management.pdf
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
STATICS OF THE RIGID BODIES Hibbelers.pdf
Ad

Get Flex 3 Cookbook Code Recipes Tips and Tricks for RIA Developers 1st Edition Joshua Noble free all chapters

  • 1. Visit https://ebookfinal.com to download the full version and explore more ebooks Flex 3 Cookbook Code Recipes Tips and Tricks for RIA Developers 1st Edition Joshua Noble _____ Click the link below to download _____ https://ebookfinal.com/download/flex-3-cookbook-code- recipes-tips-and-tricks-for-ria-developers-1st-edition- joshua-noble/ Explore and download more ebooks at ebookfinal.com
  • 2. Here are some suggested products you might be interested in. Click the link to download Getting Started with Flex 3 An Adobe Developer Library Pocket Guide for Developers 1st Edition Jack Herrington D. https://ebookfinal.com/download/getting-started-with-flex-3-an-adobe- developer-library-pocket-guide-for-developers-1st-edition-jack- herrington-d/ Adobe Photoshop CS3 Top 100 Simplified Tips Tricks Top 100 Simplified Tips Tricks 1st Edition Lynette Kent https://ebookfinal.com/download/adobe-photoshop- cs3-top-100-simplified-tips-tricks-top-100-simplified-tips-tricks-1st- edition-lynette-kent/ Oracle Internals Tips Tricks and Techniques for DBAs 1st Edition Donald K. Burleson https://ebookfinal.com/download/oracle-internals-tips-tricks-and- techniques-for-dbas-1st-edition-donald-k-burleson/ Adobe flex 3 0 for dummies 1st ed Edition Doug Mccune https://ebookfinal.com/download/adobe-flex-3-0-for-dummies-1st-ed- edition-doug-mccune/
  • 3. 100 Game Design Tips Tricks 1st Edition Wlad Marhulets https://ebookfinal.com/download/100-game-design-tips-tricks-1st- edition-wlad-marhulets/ The Allotment Cookbook Through the Year Over 200 Recipes Pick Stores Tips Preserving Ideas Caroline Bretherton https://ebookfinal.com/download/the-allotment-cookbook-through-the- year-over-200-recipes-pick-stores-tips-preserving-ideas-caroline- bretherton/ GPU Gems Programming Techniques Tips and Tricks for Real Time Graphics 1st Edition Randima Fernando https://ebookfinal.com/download/gpu-gems-programming-techniques-tips- and-tricks-for-real-time-graphics-1st-edition-randima-fernando/ Multicore Software Development Techniques Applications Tips and Tricks 1st Edition Oshana https://ebookfinal.com/download/multicore-software-development- techniques-applications-tips-and-tricks-1st-edition-oshana/ Mac Os Catalina Tricks And Tips 2020 2nd Edition Techgo https://ebookfinal.com/download/mac-os-catalina-tricks-and- tips-2020-2nd-edition-techgo/
  • 5. Flex 3 Cookbook Code Recipes Tips and Tricks for RIA Developers 1st Edition Joshua Noble Digital Instant Download Author(s): Joshua Noble, Todd Anderson ISBN(s): 9780596529857, 0596529856 Edition: 1 File Details: PDF, 6.37 MB Year: 2008 Language: english
  • 6. Flex 3 Cookbook by Joshua Noble; Todd Anderson Publisher: O'Reilly Pub Date: May 6, 2008 Print ISBN-13: 978-0-596-52985-7 Pages: 704 Table of Contents | Index Overview The best way to show off a powerful new technology is to demonstrate real-world results with it, and that's exactly what Adobe and O'Reilly have done with Flex 3. Through it's Flex Cookbook website, Adobe invited users of the Flex 3 beta to post their own solutions for working with this technology, using O'Reilly's popular problem- solution-discussion format. Website monitors (and authors) Joshua Noble and Todd Anderson chose the most useful solutions for Flex 3 Cookbook. This highly practical book contains more than 200 proven recipes for developing interactive Rich Internet Applications and Web 2.0 sites, including several contributed by Noble, Anderson, and other Flex experts. You'll find everything from Flex basics and working with menus and controls, to methods for compiling, deploying, and configuring Flex applications. Each recipe features a discussion of how and why it works, and many of them offer sample code that you can put to use immediately. Topics include: Menus and controls Containers and dialogues Working with Text List, tiles, trees, and repeaters DataGrid and Advanced DataGrid Renderers Images, videos, and sounds CSS and skinning Building components States and effects Collections, arrays, and DataProviders Flex 3 Cookbook by Joshua Noble; Todd Anderson Publisher: O'Reilly Pub Date: May 6, 2008 Print ISBN-13: 978-0-596-52985-7 Pages: 704 Table of Contents | Index Overview The best way to show off a powerful new technology is to demonstrate real-world results with it, and that's exactly what Adobe and O'Reilly have done with Flex 3. Through it's Flex Cookbook website, Adobe invited users of the Flex 3 beta to post their own solutions for working with this technology, using O'Reilly's popular problem- solution-discussion format. Website monitors (and authors) Joshua Noble and Todd Anderson chose the most useful solutions for Flex 3 Cookbook. This highly practical book contains more than 200 proven recipes for developing interactive Rich Internet Applications and Web 2.0 sites, including several contributed by Noble, Anderson, and other Flex experts. You'll find everything from Flex basics and working with menus and controls, to methods for compiling, deploying, and configuring Flex applications. Each recipe features a discussion of how and why it works, and many of them offer sample code that you can put to use immediately. Topics include: Menus and controls Containers and dialogues Working with Text List, tiles, trees, and repeaters DataGrid and Advanced DataGrid Renderers Images, videos, and sounds CSS and skinning Building components States and effects Collections, arrays, and DataProviders
  • 7. DataBinding Validation/formatters Charting and data visualization State management, SharedObjects and LocalConnection Working with services and ServerSide communication Working with XML Communicating with the browser Application development strategies Runtime and dynamic shared libraries and modules Working with Adobe AIR Whether you're a committed Flex developer, or still evaluating the technology, you'll discover how to get quick results with Flex 3 using these these recipes. Now that Flex is an open source framework, the user community will continue to supply solutions to extend and improve the technology. This Cookbook offers you the cream of the crop.
  • 8. Flex 3 Cookbook by Joshua Noble; Todd Anderson Publisher: O'Reilly Pub Date: May 6, 2008 Print ISBN-13: 978-0-596-52985-7 Pages: 704 Table of Contents | Index Copyright Preface Chapter 1. Flex and ActionScript Basics Recipe 1.1. Create a Flex Project in Flex Builder Recipe 1.2. Create a Flex Library Project in Flex Builder Recipe 1.3. Create an ActionScript Project Recipe 1.4. Set Compiler Options for the MXML Compiler in Flex Builder Recipe 1.5. Compile a Flex Project Outside of Flex Builder Recipe 1.6. Add an Event Listener in MXML Recipe 1.7. Set Properties of a Child Defined in MXML in ActionScript Recipe 1.8. Define Arrays and Objects Recipe 1.9. Set the Scope of Variables in ActionScript Recipe 1.10. Create a Component in ActionScript Recipe 1.11. Use Event Bubbling Recipe 1.12. Use a Code-Behind Model to Separate MXML and ActionScript Recipe 1.13. Make Properties of a Component Bindable Recipe 1.14. Use Custom Events and Dispatch Data with Events Recipe 1.15. Listen for a Keyboard Event Recipe 1.16. Define Optional Parameters for Methods Recipe 1.17. Determine the Type of an Object Recipe 1.18. Define and Implement an Interface Chapter 2. Menus and Controls Recipe 2.1. Listen to a Button Click Recipe 2.2. Create a Set of Buttons That Toggle Recipe 2.3. Use a ColorPicker to Set Canvas Color Recipe 2.4. Load a SWF by Using the SWFLoader Recipe 2.5. Set Tab Indexes for Components Recipe 2.6. Set a labelFunction for a Control Recipe 2.7. Provide Data for Menus Recipe 2.8. Dynamically Populate Menus Recipe 2.9. Create EventHandlers for Menu-Based Controls Recipe 2.10. Display an Alert in an Application Recipe 2.11. Use the Date from a Calendar Control Recipe 2.12. Display and Position Multiple Pop-ups Recipe 2.13. Create a Custom Border for a Pop-up Window Recipe 2.14. Handle focusIn and focusOut Events Chapter 3. Containers Recipe 3.1. Position Children by Using Layout Management Recipe 3.2. Position and Size Containers via Percentage Positioning Recipe 3.3. Track Mouse Position Within Different Coordinate Systems Recipe 3.4. Dynamically Add and Remove Children from a Container Recipe 3.5. Use Constraint-Based Layout for Containers Recipe 3.6. Set Maximum and Minimum Sizes for Children Within Containers Recipe 3.7. Specify Constraint Rows and Columns for a Container Recipe 3.8. Create Layout Flows for Text Using Constraints Recipe 3.9. Control Scrolling and Overflow Within Containers Recipe 3.10. Control the Layout of Box Components Recipe 3.11. Use Containers for Initialization Recipe 3.12. Create a TitleWindow Recipe 3.13. Control a ViewStack via a LinkBar Recipe 3.14. Bind the Selected Index of a ViewStack to a Variable
  • 9. Recipe 3.15. Use Delayed Instantiation to Improve Startup Time Recipe 3.16. Create and Control Resizable Containers Recipe 3.17. Create, Enable, and Disable TabControls Within a TabNavigator Recipe 3.18. Create a TabNavigator with Closeable Tabs Recipe 3.19. Create and Control an Alert Recipe 3.20. Size and Position a Dialog Box Based on Its Calling Component Recipe 3.21. Manage Multiple Pop-up Dialog Boxes Recipe 3.22. Scroll to a Specific Child in a Container Recipe 3.23. Create a Template Using IDeferredInstance Recipe 3.24. Manually Lay Out a Container Recipe 3.25. Measure and Alter Container Size Recipe 3.26. Control the Visibility and Layout of Children Recipe 3.27. Create a Tile Container with Simple Reorganization Recipe 3.28. Set a Background Image and Rounded Corners in an HBox Recipe 3.29. Control Positioning and Scrolling of Child Components Chapter 4. Text Recipe 4.1. Correctly Set the Value of a Text Object Recipe 4.2. Bind a Value to TextInput Recipe 4.3. Create a Suggestive TextInput Recipe 4.4. Create an In-Place Editor Recipe 4.5. Determine All Fonts Installed on a User's Computer Recipe 4.6. Create a Custom TextInput Recipe 4.7. Set the Style Properties for Text Ranges Recipe 4.8. Display Images and SWFs in HTML Recipe 4.9. Highlight User-Input Text in a Search Field Recipe 4.10. Manipulate Characters as Individual Graphics Recipe 4.11. Specify Styles for HTML in a TextField Recipe 4.12. Use the RichTextEditor Recipe 4.13. Apply Embedded Fonts with HTML Recipe 4.14. Add a Drop Shadow to Text in a Text Component Recipe 4.15. Find the Last Displayed Character in a TextArea Chapter 5. Lists, Tiles, and Trees Recipe 5.1. Create an Editable List Recipe 5.2. Set Icons for Items in a List Recipe 5.3. Add Effects to a List to Indicate Changes Recipe 5.4. Set a Basic Item Renderer for a TileList Recipe 5.5. Set XML Data for a Tree Recipe 5.6. Create an Item Renderer for a Tree Recipe 5.7. Use Complex Data Objects in a Tree Control Recipe 5.8. Allow Only Certain Items in a List to Be Selectable Recipe 5.9. Format and Validate Data Added in a List's Item Editor Recipe 5.10. Track All Selected Children in a TileList Recipe 5.11. Use and Display Null Items in an Item Renderer Recipe 5.12. Create a Right-Click Menu for a List Recipe 5.13. Customize the Appearance of a Selection in a List Chapter 6. DataGrid and Advanced DataGrid Recipe 6.1. Create Custom Columns for a DataGrid Recipe 6.2. Specify Sort Functions for DataGrid Columns Recipe 6.3. Enable Multicolumn Sorting in a DataGrid Recipe 6.4. Filter Items in a DataGrid Recipe 6.5. Create Custom Headers for an AdvancedDataGrid Recipe 6.6. Handle Events from a DataGrid/AdvancedDataGrid Recipe 6.7. Select Items in an AdvancedDataGrid Recipe 6.8. Enable Drag-and-Drop in a DataGrid Recipe 6.9. Edit Items in a DataGrid Recipe 6.10. Search Within a DataGrid and Autoscroll to the Match Recipe 6.11. Generate a Summary for Flat Data by Using GroupingCollection Recipe 6.12. Create an Async Refresh for a GroupingCollection Chapter 7. Renderers and Editors Recipe 7.1. Create Your Own Renderers Recipe 7.2. Use the ClassFactory to Generate Renderers Recipe 7.3. Access the Component That Owns a Renderer Recipe 7.4. Create a Single Component to Act as Renderer and Editor Recipe 7.5. Create an Item Editor to Handle Data with Multiple Fields
  • 10. Recipe 7.6. Display SWF Objects as Items in a Menu by Using an Item Renderer Recipe 7.7. Select a DataGrid Column with a CheckBox Header Renderer Recipe 7.8. Create a Self-Contained CheckBox itemRenderer for Use in a DataGrid Recipe 7.9. Efficiently Set Images in a Renderer Recipe 7.10. Use Runtime Styling with itemRenderers and itemEditors Recipe 7.11. Use States and Transitions with an itemEditor Recipe 7.12. Create a CheckBox Tree Control Recipe 7.13. Resize Renderers Within a List Chapter 8. Images, Bitmaps, Videos, Sounds Recipe 8.1. Load and Display an Image Recipe 8.2. Create a Video Display Recipe 8.3. Play and Pause an MP3 File Recipe 8.4. Create a Seek Bar for a Sound File Recipe 8.5. Blend Two Images Recipe 8.6. Apply a Convolution Filter to an Image Recipe 8.7. Send Video to an FMS Instance via a Camera Recipe 8.8. Access a User's Microphone and Create a Sound Display Recipe 8.9. Smooth Video Displayed in a Flex Application Recipe 8.10. Check Pixel-Level Collisions Recipe 8.11. Read and Save a User's Webcam Image Recipe 8.12. Use Blend Modes with Multiple Images Recipe 8.13. Handle Cue Points in FLV Data Recipe 8.14. Create a Video Scrubber Recipe 8.15. Read ID3 Data from an MP3 File Recipe 8.16. Display a Custom Loader while Loading Images Recipe 8.17. Enable Image Upload in Flex Recipe 8.18. Compare Two Bitmap Images Chapter 9. Skinning and Styling Recipe 9.1. Use CSS to Style Components Recipe 9.2. Override the Default Application Style Recipe 9.3. Embed Styles by Using CSS Recipe 9.4. Override Base Style Properties Recipe 9.5. Customize Styles at Runtime Recipe 9.6. Load CSS at Runtime Recipe 9.7. Declare Styles at Runtime Recipe 9.8. Create Custom Style Properties for Components Recipe 9.9. Use Multiple Themes in the Same Application Recipe 9.10. Compile a Theme SWC Recipe 9.11. Use Embedded Fonts Recipe 9.12. Embed Fonts from a SWF File Recipe 9.13. Skin with Embedded Images Recipe 9.14. Apply Skins from a SWF File Recipe 9.15. Programmatically Skin a Component Recipe 9.16. Programmatically Skin a Stateful Control Recipe 9.17. Create Animated Skins from a SWF File Recipe 9.18. Customize the Preloader Chapter 10. Dragging and Dropping Recipe 10.1. Use the DragManager Class Recipe 10.2. Specify a Drag Proxy Recipe 10.3. Drag and Drop Within a List Recipe 10.4. Drag and Drop Between Lists Recipe 10.5. Enable and Disable Drag Operations Recipe 10.6. Customize the DragImage of a List-Based Control Recipe 10.7. Customize the Drop Indicator of a List-Based Control Chapter 11. States Recipe 11.1. Set Styles and Properties in a State Recipe 11.2. Create Transitions to Enter and Leave States Recipe 11.3. Use the AddChildAction and RemoveChildAction Recipe 11.4. Filter Transitions to Affect Only Certain Types of Children Recipe 11.5. Apply Parts of a Transition to Certain Children Recipe 11.6. Base a State on Another State Recipe 11.7. Integrate View States with HistoryManagement Recipe 11.8. Use Deferred Instance Factories with States Recipe 11.9. Use Data Binding with Objects Added in a State
  • 11. Recipe 11.10. Add and Remove Event Listeners in State Changes Recipe 11.11. Add View States to a Flash Component Recipe 11.12. Work with State Change Events Recipe 11.13. Dynamically Generate and Use New States and Transitions Recipe 11.14. Create Custom Actions to Use in a State Chapter 12. Effects Recipe 12.1. Call an Effect in MXML and in ActionScript Recipe 12.2. Build a Custom Effect Recipe 12.3. Create Parallel Series or Sequences of Effects Recipe 12.4. Pause, Reverse, and Restart an Effect Recipe 12.5. Create Custom Effect Triggers Recipe 12.6. Create Tween Effects Recipe 12.7. Use the DisplacementMapFilter Filter in a Flex Effect Recipe 12.8. Create an AnimateColor Effect Recipe 12.9. Use the Convolution Filter to Create a Tween Chapter 13. Collections Recipe 13.1. Add, Sort, and Retrieve Data from an ArrayCollection Recipe 13.2. Filter an ArrayCollection Recipe 13.3. Determine When an Item Is Modified in an ArrayCollection Recipe 13.4. Create a GroupingCollection Recipe 13.5. Create a Hierarchical Data Provider for a Control Recipe 13.6. Navigate a Collection Object and Save Your Position Recipe 13.7. Create a HierarchicalViewCollection Object Recipe 13.8. Filter and Sort an XMLListCollection Recipe 13.9. Sort on Multiple Fields in a Collection Recipe 13.10. Sort on Dates in a Collection Recipe 13.11. Create a Deep Copy of an ArrayCollection Recipe 13.12. Use Data Objects with Unique IDs Chapter 14. Data Binding Recipe 14.1. Bind to a Property Recipe 14.2. Bind to a Function Recipe 14.3. Create a Bidirectional Binding Recipe 14.4. Bind to Properties by Using ActionScript Recipe 14.5. Use Bindable Property Chains Recipe 14.6. Bind to Properties on XML by Using E4X Recipe 14.7. Create Customized Bindable Properties Recipe 14.8. Bind to a Generic Object Recipe 14.9. Bind to Properties on a Dynamic Class Chapter 15. Validation, Formatting, and Regular Expressions Recipe 15.1. Use Validators and Formatters with TextInput and TextArea Controls Recipe 15.2. Create a Custom Formatter Recipe 15.3. Create a More-International Zip Code Validator by Using Regular Expressions Recipe 15.4. Create a Validator to Validate UPCs Recipe 15.5. Validate Combo Boxes and Groups of Radio Buttons Recipe 15.6. Show Validation Errors by Using ToolTips in a Form Recipe 15.7. Use Regular Expressions for Locating Email Addresses Recipe 15.8. Use Regular Expressions for Matching Credit Card Numbers Recipe 15.9. Use Regular Expressions for Validating ISBNs Recipe 15.10. Create Regular Expressions by Using Explicit Character Classes Recipe 15.11. Use Character Types in Regular Expressions Recipe 15.12. Match Valid IP Addresses by Using Subexpressions Recipe 15.13. Use Regular Expressions for Different Types of Matches Recipe 15.14. Match Ends or Beginnings of Lines with Regular Expressions Recipe 15.15. Use Back-References Recipe 15.16. Use a Look-Ahead or Look-Behind Chapter 16. Charting Recipe 16.1. Create a Chart Recipe 16.2. Add Effects to Charts Recipe 16.3. Select Regions of a Chart Recipe 16.4. Format Tick Marks for a Chart Recipe 16.5. Create a Custom Label for a Chart Recipe 16.6. Create a Drill-Down Effect for a Columnar Chart Recipe 16.7. Skin Chart Items Recipe 16.8. Use ActionScript to Dynamically Add and Remove Columns for a Chart
  • 12. Recipe 16.9. Overlap Multiple ChartSeries Recipe 16.10. Drag and Drop Items in a Chart Recipe 16.11. Create an Editable Line Chart Chapter 17. SharedObjects Recipe 17.1. Create a SharedObject Recipe 17.2. Write Data into a SharedObject Recipe 17.3. Save a Local SharedObject Recipe 17.4. Read Data from a SharedObject Recipe 17.5. Remove Data from a SharedObject Recipe 17.6. Serialize Typed Objects Recipe 17.7. Access a SharedObject Between Multiple Flash Applications Recipe 17.8. Remember TextInput Values for Returning Users Chapter 18. Working with Services and Server-Side Communication Recipe 18.1. Configure an HTTPService Recipe 18.2. Use RESTful Communication Between Flex Applications Recipe 18.3. Configure and Connect to a RemoteObject Recipe 18.4. Use Flex Remoting with AMFPHP 1.9 Recipe 18.5. Use the IExternalizable Interface for Custom Serialization Recipe 18.6. Track Results from Multiple Simultaneous Service Calls Recipe 18.7. Use Publish/Subscribe Messaging Recipe 18.8. Register a Server-Side Data Type Within a Flex Application Recipe 18.9. Communicate with a WebService Recipe 18.10. Add a SOAP Header to a Request to a WebService Recipe 18.11. Parse a SOAP Response from a WebService Recipe 18.12. Communicate Securely with AMF by Using SecureAMFChannel Recipe 18.13. Send and Receive Binary Data via a Binary Socket Recipe 18.14. Communicate Using an XMLSocket Chapter 19. XML Recipe 19.1. Load an XML File Recipe 19.2. Navigate an XML Document in E4X Recipe 19.3. Use Regular Expressions in E4X Queries Recipe 19.4. Add an XMLList to an XML Object Recipe 19.5. Bind to an XMLList or an E4X Query Recipe 19.6. Generate XML Objects from Arrays Recipe 19.7. Handle Namespaces in XML Returned by a Service Recipe 19.8. Encode an ActionScript Data Object as XML Recipe 19.9. Populate a Component with Complex XML Data Recipe 19.10. Decode XML from a Web Service into Strongly Typed Objects Chapter 20. Browser Communication Recipe 20.1. Link to an External URL Recipe 20.2. Work with FlashVars Recipe 20.3. Invoke JavaScript Functions from Flex Recipe 20.4. Invoke ActionScript Functions from JavaScript Recipe 20.5. Change the HTML Page Title via BrowserManager Recipe 20.6. Parse the URL via BrowserManager Recipe 20.7. Deep-Link to Data via BrowserManager Recipe 20.8. Deep-Link Containers via BrowserManager Recipe 20.9. Implement Custom History Management Chapter 21. Development Strategies Recipe 21.1. Use the Flex Component Kit to Create Components Recipe 21.2. Use the ContainerMovieClip to Create Flex Containers in Flash Recipe 21.3. Import Components from Flash CS3 Recipe 21.4. Get Started with the Cairngorm Architecture Recipe 21.5. Create a Cairngorm View, Event, and Model Recipe 21.6. Create Cairngorm Commands and a Business Delegate Class Recipe 21.7. Create a Cairngorm FrontController and a ServiceLocator Recipe 21.8. Generate an Application Structure with the Cairngen Framework Generator Recipe 21.9. Learn Common Performance-Tuning Tricks Recipe 21.10. Create Custom Metadata Properties for a Component Chapter 22. Modules and Runtime Shared Libraries Recipe 22.1. Create a Runtime Shared Library Recipe 22.2. Use Cross-Domain Runtime Shared Libraries Recipe 22.3. Use the Flex Framework as a Runtime Shared Library Recipe 22.4. Optimize a Runtime Shared Library
  • 13. Recipe 22.5. Create an MXML-Based Module Recipe 22.6. Create an ActionScript-Based Module Recipe 22.7. Load a Module by Using ModuleLoader Recipe 22.8. Use ModuleManager to Load Modules Recipe 22.9. Load Modules from Different Servers Recipe 22.10. Communicate with a Module Recipe 22.11. Pass Data to Modules by Using Query Strings Recipe 22.12. Optimize Modules by Using Linker Reports Chapter 23. The Adobe Integrated Runtime API Recipe 23.1. Create an AIR Application Leveraging the Flex Framework Recipe 23.2. Understand the AIR Command-Line Tools Recipe 23.3. Open and Manage Native Windows Recipe 23.4. Create Native Menus Recipe 23.5. Read and Write to a File Recipe 23.6. Serialize Objects Recipe 23.7. Use the Encrypted Local Store Recipe 23.8. Browse for Files Recipe 23.9. Use the AIR File System Controls Recipe 23.10. Use the Native Drag-and-Drop API Recipe 23.11. Interact with the Operating System Clipboard Recipe 23.12. Add HTML Content Recipe 23.13. Cross-Script Between ActionScript and JavaScript Recipe 23.14. Work with Local SQL Databases Recipe 23.15. Detect and Monitor a Network Connection Recipe 23.16. Detect User Presence Recipe 23.17. Create System Tray and Dock Applications Chapter 24. Unit Testing with FlexUnit Recipe 24.1. Create an Application That Uses the FlexUnit Framework Recipe 24.2. Create an Application to Run FlexUnit Tests Recipe 24.3. Create a FlexUnit Test Case Recipe 24.4. Add a Test Case to a Test Suite Recipe 24.5. Run Code Before and After Every Test Recipe 24.6. Share Test Data Between Test Cases Recipe 24.7. Handle Events in a Test Case Recipe 24.8. Test Visual Components with FlexUnit Recipe 24.9. Install and Configure Antennae Recipe 24.10. Generate Automated Test Suites Chapter 25. Compiling and Debugging Recipe 25.1. Use Trace Statements Without Flex Builder Recipe 25.2. Use the Component Compiler Recipe 25.3. Install the Flex Ant Tasks Recipe 25.4. Use the compc and mxmlc Tasks in the Flex Ant Tasks Recipe 25.5. Compile and Deploy Flex Applications That Use RSLs Recipe 25.6. Create and Monitor Expressions in Flex Builder Debugging Recipe 25.7. Install the Ant View in the Stand-Alone Version of Flex Builder Recipe 25.8. Create an Ant Build File for Automating Common Tasks Recipe 25.9. Compile a Flex Application by Using mxmlc and Ant Recipe 25.10. Generate Documentation by Using ASDoc and Ant Recipe 25.11. Compile Flex Applications by Using Rake Recipe 25.12. Use ExpressInstall for Your Application Recipe 25.13. Use Memory Profiling with Flex Builder 3 to View Memory Snapshots Chapter 26. Configuration, Internationalization, and Printing Recipe 26.1. Add an International Character Set to an Application Recipe 26.2. Use a Resource Bundle to Localize an Application Recipe 26.3. Use the ResourceManager for Localization Recipe 26.4. Use Resource Modules for Localization Recipe 26.5. Support IME Devices Recipe 26.6. Detect a Screen Reader Recipe 26.7. Create a Tabbing Reading Order for Accessibility Recipe 26.8. Print Selected Items in an Application Recipe 26.9. Format Application Content for Printing Recipe 26.10. Control Printing of Unknown Length Content over Multiple Pages Recipe 26.11. Add a Header and a Footer When Printing Index
  • 15. Copyright Copyright © 2008, Joshua Noble and Todd Anderson. All rights reserved. Printed in the United States of America. Published by O'Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472. O'Reilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (http://safari.oreilly.com). For more information, contact our corporate/institutional sales department: (800) 998-9938 or corporate@oreilly.com. Editor: Linda Laflamme Production Editor: Michele Filshie Editor: Sharon Wilkey The O'Reilly logo is a registered trademark of O'Reilly Media, Inc. Flex 3 Cookbook, the image of the fringed gecko, and related trade dress are trademarks of O'Reilly Media, Inc. Many of the designations uses by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and O'Reilly Media, Inc. was aware of a trademark claim, the designations have been printed in caps or initial caps While every precaution has been taken in the preparation of this book, the publisher and authors assume no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein.
  • 16. Preface Flex 3 is a powerful framework that provides enterprise-level components for the Flash Player platform in a markup language format recognizable to anyone with HTML or XML development experience. The Flex Framework provides components for visual layout, visual effects, data grids, server communication, charts, and much more. To put a blunt point on it, the Flex Framework is massive, and any book attempting to cover the entire Framework in any depth will without question fail in some respect or another. With this in mind, we've made an attempt to cover the topics that most vex developers working with Flex 3—in a way that can illuminate how the Framework is structured as well as help solve common problems. The official Flex documentation is quite good at explaining in depth how particular methods or classes behave, so instead we explain how to tackle common tasks within the Flex Framework, how to get different components to work together, and how Flex can partner with other technologies to create Rich Internet Applications and more. With the help of Adobe AIR, for example, you can use the tools of Flex and the Flash Player to create deployable desktop applications. This complements the expansion of open source and commercial tools for Java, .NET, and PHP development, among others, making Flex a powerful solution for an ever wider range of development needs and challenges. Recipe P.1. Bonus Chapters Online The Flex framework is such a huge topic and we had so many recipes and so much information to cover that we simply couldn't fit it all into the printed book. Four chapters totaling 76 pages are available to you online that cover working with XML, the Charting components, working with SharedObjects, and Development Strategies for creating Flex applications. Go to www.oreilly.com/catalog/9780596529857 to read this bonus material. Recipe P.2. Who This Book Is For Flex 3 Cookbook is for developers who want to understand the Flex Framework more thoroughly or who need a reference to consult to solve particular problems. As such, this book assumes that you have some previous experience with Flex and ActionScript 3. The code samples and explanations likewise are geared toward intermediate developers familiar with the relationship between MXML and ActionScript, at least some of the components that make up the Flex Framework, and basic strategies of Flex development. We have made a very deliberate decision to ensure that all the recipes contain usable components and functional, tested implementations of those components. This was not done with the intention of swelling the book unreasonably, but to ensure that this book is suitable for intermediate and advanced developers who simply need to see a small code snippet to understand a technique, as well as readers who are still learning how the Flex Framework can be used and the best practices for working with it. Recipe P.3. Who This Book Is Not For If you need to learn the Flex Framework from scratch, consult Programming Flex 3 by Joey Lott and Chafic Kazoun (O'Reilly, 2008) to gain an understanding of the core concepts of Flex development before reading any further here. With a grounding in Flex and ActionScript basics, you'll be better prepared to take advantage of the techniques in this book. If you need a refresher course in ActionScript development, try ActionScript 3.0 Cookbook by Joey Lott, Darron Schall, and Keith Peters (O'Reilly, 2006) for techniques focused on core Flash ActionScript programming. Although Flex 3 Cookbook covers some areas of overlap between the Flex Framework and core Flash ActionScript classes, this book is very much focused on Flex development. Recipe P.4. How This Book Is Organized As its name implies, Flex 3 Cookbook is stuffed full with recipes for techniques that will help you get more from
  • 17. your Flex applications. To help you find the solutions you need faster, the recipes are organized by theme. Generally the recipes progress from simpler topics to the more complex throughout each chapter. This book was not intended to be read from cover to cover but rather to be used as a reference for a particular problem, or to provide some insight into a particular aspect of the Flex Framework. The recipes also include complete component implementations to show you how to completely implement the concept discussed. You should be able to use the demonstrated code in your own applications or at the very minimum adapt relevant portions of the code to your needs. P.5. Conventions Used in This Book The following typographical conventions are used in this book: Italic Indicates new terms, URLs, email addresses, filenames, and file extensions. Constant width 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 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 or by values determined by context. P.6. 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: "Flex 3 Cookbook by Joshua Noble and Todd Anderson. Copyright 2008 Joshua Noble and Todd Anderson, 978-0-596-5298-57." If you feel your use of code examples falls outside fair use or the permission given above, feel free to contact us
  • 18. at permissions@oreilly.com. P.7. How to Use This Book Think of this book like a friend and a counselor. Don't put it on a shelf. Keep it on your desk where you can consult it often. When you are uncertain as to how something works or how to approach a specific programming issue pick up the book and flip to the relevant recipe(s). We have written this book in a format so that you can get answers to specific questions quickly. And since it's a book you don't ever have to worry that it will laugh at you for asking questions. No question is too big or too small. Although you can read the book from cover to cover, we encourage you to use this book when you need an answer. Rather than teaching you a bunch of theory, this book intends to help you solve problems and accomplish tasks. This book is meant for field work, not the research lab. P.8. O'Reilly Cookbooks 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: Problem Each Problem addressed in an O'Reilly Cookbook is clearly stated, specific, and practical. Solution The Solution is easy to understand and implement. Discussion The Discussion clarifies and explains the context of the Problem and the Solution. It also contains sample code to show you how to get the job done. Best of all, all of the sample code you see in an O'Reilly Cookbook can be downloaded from the book's web site, at http://www.oreilly.com/catalog/actscpt3ckbk. See Also The See Also section directs you to additional information related to the topic covered in the recipe. You'll find pointers to other recipes in the book, to other books (including non-O'Reilly titles), web sites, and more. To learn more about the O'Reilly Cookbook series, or to find other Cookbooks that are up your alley, visit their
  • 19. web site at http://cookbooks.oreilly.com. P.9. Safari® Enabled NOTE When you see a Safari® Enabled 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. P.10. How to Contact Us 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/9780596529857 To comment or ask technical questions about this book, send email to: bookquestions@oreilly.com For more information about our books, conferences, Resource Centers, and the O'Reilly Network, see our web site at: http://www.oreilly.com Recipe P.11. Acknowledgments This book truly does represent a product of the Flex community. Thanks belong to many developers and the community relations managers at Adobe, Amy Wong, Matt Chotin, Ely Greenfield, and Alex Harui in particular, as well as to the developers who work with Adobe products and contributed to the Flex Cookbook site or blogged about what they discovered. Without all of them, this book would not be conceivable. Many, many thanks are due to the many people at O'Reilly who made this book possible. Many special thanks go to Steve Weiss, Linda Laflamme, and Michele Filshie for their hard work, flexibility, and patience throughout the writing and editing of this book.
  • 20. The quality of the technical information within this book is not simply due to the knowledge of the many authors of this book. The technical reviewers for this book, Mark Walters (http://www.digitalflipbook.com/), Alfio Raymond, and Jen Blackledge, not only provided help debugging, correcting, and clarifying the code for this book, but also provided fantastic insight into ways to clarify explanations, structure chapters, alter recipes, and help the readers' understanding. Recipe P.11.1. From Joshua First and foremost, I need to thank Joey Lott for so graciously helping me get the opportunity to write this book and the one before this. I wouldn't be writing this without his encouragement and advocacy for my abilities, and I can't thank him enough for believing in me enough to recommend me for this book. The same goes to Steve Weiss, who took a chance on a somewhat unknown author and made it possible for the book to blossom to its current size. To my co-authors, Todd Anderson and Abey George, and also the people at Cynergy Systems, Andrew Trice, Craig Drabnik, Keun Lee, and Ryan Miller, for stepping in and helping when I needed them, to all of them I owe a huge debt. I also need to thank Daniel Rinehart, who did such a fantastic job writing the recipes that make up "Unit Testing with FlexUnit," simply to educate and share with the Flex community, completely unprompted. The same goes for everyone who participated in the Adobe Cookbook site and on forums like FlexCoders, making a vibrant, helpful community that helps us all. I'd also like to thank my friends whom I've known from jobs and from life, for providing me with so much help, advice, support, and humor. Finally, I'd like to thank my family, and in particular my mother, for always providing me with encouragement and wisdom. Recipe P.11.2. From Todd I would first like to thank Josh Noble for asking me to participate in this book and for providing knowledge, patience, and humor throughout. I'd also like to thank Joey Lott for his huge encouragement and belief in people's abilities. I'd like to thank my friends and the Flash community for offering advice, a few laughs, and expertise. And finally to my family, I cannot thank you enough for the huge love and support. Recipe P.12. Author Bios Joshua Noble, a development consultant based in New York City, is the co-author of ActionScript 3.0 Bible (Wiley, 2007). He has worked with Flex and Flash on a wide range of web applications on a variety of platforms over the past six years as well as working with PHP, Ruby, Erlang, and C#. In his free time, he enjoys playing with C++ and OpenCV as well as using microcontrollers and sensors to create reactive environments. His website is http://thefactoryfactory.com. Todd Anderson is a senior software engineer for Infrared5. With over five years of developing for the Flash platform in the areas of RIA and game development, Todd has delivered web and desktop solutions for the publishing and entertainment industries with companies including McGraw-Hill, Thomson, Motorola, and Condé Nast Publications. Currently residing in the Boston area, when he's not programming he likes to get back to his fine arts roots and build things on paper. Anderson runs www.custardbelly.com/blog, focusing on development of the Flash platform. P.13. Contributor Bios Abey George is a software engineer with expertise in architecting and developing Rich Internet Applications (RIAs). He has implemented a wide range of RIA solutions for both web and enterprise applications by using a combination of Flex, Flash, and C#. He holds an MS from Texas A&M University and has over six years of professional experience in the field of software engineering. Interested in effectively leveraging RIAs in the enterprise, Abey is currently a principal software engineer at Fidelity Investments and has worked previously for Yahoo, Keane, and Mindseye. Daniel Rinehart is a software architect at Allurent, where he is helping to build a new generation of innovative online shopping experiences using Flex. He has worked in the field of software development as an engineer and
  • 21. architect for the past eight years. Prior to joining Allurent, Daniel worked at Ruckus Network, Towers Perrin, and Bit Group, where his clients included Cisco and Dell Financial Services. He can be reached on the Web at http://danielr.neophi.com/. Andrew Trice is the principal architect for Flex and AIR for Cynergy Systems. He specializes in data visualization, client-server architectures, object-oriented principles, and rich application development. He has been developing for the Web for over 10 years, with over eight years of development for the Flash platform. Thriving on the creativity and flexibility that the Flex/Flash platform enable, Andrew has developed with Flex since version 1.5. Andrew also possesses over seven years' experience with ColdFusion, is a Microsoft Certified Application Developer, and has a wide range of knowledge regarding relational databases, Ajax/JavaScript, .NET, and Java web applications. Keun Lee is a technical lead for Cynergy Systems. He specializes in technologies such as Adobe Flex and the Microsoft Windows Presentation Foundation. He has an extensive background in business intelligence, B2B application architecture, and Rich Internet Application development. In his spare time, he enjoys playing and composing music and in general building cool things with the abundance of available technology at his disposal. Craig Drabik has been building web applications since 2000 by using DHTML, ColdFusion, Flash, and Flex. He currently works for Cynergy Systems, leading the implementation of customer Flex projects. Ryan Taylor is an award-winning artist and programmer specializing in object-oriented Flash development and static/motion design. He currently serves as a senior developer on the Multimedia Platforms Group at Schematic. Ryan frequently speaks at industry events and shares all of his thoughts, experiments, and open source contributions on his blog at www.boostworthy.com/blog. Marco Casario founded Comtaste (www.comtaste.com), a company dedicated to exploring new frontiers in Rich Internet Applications and the convergence of the Web and the world of mobile devices. He is the author of the Flex Solutions: Essential Techniques for Flex 2 and Flex 3 Developers (Friends of ED, 2007) and Advanced AIR Applications (Friends of ED, 2008). Marco often speaks at such conferences as Adobe MAX, O'Reilly Web 2.0 Summit, FITC, AJAXWorld Conference & Expo, 360Flex, From A to Web, AdobeLive, and many others, details of which are on his blog at http://casario.blogs.com. Andrei Ionescu is a Romanian web developer who likes new technologies and making them interact. He enjoys making and implementing Rich Internet Applications in the best possible way and bringing to life all kinds of web applications. He is author of the Flex blog www.flexer.info, and his company site is www.designit.ro. Ryan Miller has been developing web applications for more than seven years. Working for companies big and small, he's managed to get his hands all kinds of dirty over the years. Currently he works out of his Beaverton, Oregon home for Cynergy Systems doing Flex development, all day, every day, and loving every minute. P.14. Colophon The animal on the cover is a fringed gecko. The cover image is from Wood's Animate Creation. The cover font is Adobe ITC Garamond. The text font is Linotype Birka; the heading font is Adobe Myriad Condensed; and the code font is LucasFont's TheSansMomoCondensed.
  • 22. Chapter 1. Flex and ActionScript Basics A Flex application consists primarily of code written in two different languages: ActionScript and MXML. Now in its 3.0 incarnation, ActionScript has gone from a prototype-based scripting language to a fully object-oriented, strictly typed, ECMAScript language. MXML is a markup language that will feel comfortable immediately to anyone who has spent time working with Hypertext Markup Language (HTML), Extensible Markup Language (XML), or a host of newer markup-based languages. How do MXML and ActionScript relate to one another? The compiler, after parsing through the different idioms, translates them into the same objects, so that <mx:Button id="btn" label="My Button" height="100"/> and var btn:Button = new Button(); btn.label = "My Button"; btn.height = 100; produce the same object. The major difference is that whereas creating that object in ActionScript (second example) creates the button and nothing else, creating the object in MXML adds the button to whatever component contains the MXML code. The Flex Framework handles calling the constructor of the object described in MXML and either adding it to the parent or setting it as a property of a parent. MXML files can include ActionScript within an <mx:Script> tag, but ActionScript files cannot include MXML. Although it's tempting to think of MXML as the description of the appearance and components that make up your application, and of ActionScript as the description of the event handlers and custom logic your application requires, this is not always true. A far better way to think of their relationship is to understand that both languages ultimately describe the same objects via different syntax. Certain aspects of the Flash platform cannot be accessed without using ActionScript for loops, function declarations, and conditional statements, among many others. This is why the use of ActionScript and the integration between MXML and ActionScript is necessary for all but the very simplest applications. This chapter discusses many aspects of integrating MXML and ActionScript: creating components in MXML, creating classes in ActionScript, adding event listeners, creating code-behind files by using ActionScript and MXML, and creating function declarations. Although it doesn't contain all the answers, it will get you started with the basics of ActionScript and MXML. Recipe 1.1. Create a Flex Project in Flex Builder Recipe 1.1.1. Problem You want to create a project in Flex Builder. Recipe 1.1.2. Solution Use the Create New Project wizard. Recipe 1.1.3. Discussion Flex Builder is built on top of Eclipse, the venerable and well-respected integrated development environment (IDE) most strongly associated with Java development. Although Flex Builder certainly is not necessary for Flex
  • 23. development, it is the premier tool for creating Flex applications and as such provides a wealth of features to help you design and develop applications more effectively. You can use Flex Builder either as a stand-alone application or as a plug-in to an existing installation of Eclipse. The first thing you need to do as a Flex developer is to create a Flex project. A Flex project is different from the other types of projects in Flex Builder because it includes theSWC (Flex library) Flex library SWC (unlike an ActionScript project) and is compiled to a SWF file that can be viewed in the Flash Player (unlike a Flex Library project). To create a project, right-click or Control-click (Mac) in Flex Builder's project navigator to display the contextual menu (Figure 1-1), or use the File menu at the top of the application. From either, choose New Flex Project. A dialog box appears to guide you through creating a project. Figure 1-1. Creating a new Flex project When prompted to specify how the project will get its data, choose Basic, which brings you to the New Flex Project dialog box (Figure 1-2). Figure 1-2. Creating a new project in Flex Builder
  • 24. Enter an application name and below, a location where the files will be stored on your system. The default location is C:/Documents and Settings/Username/Documents/workspace/Projectname on a Windows machine, and Users/Username/Documents/workspace/Projectname on a Mac. You can of course, uncheck Use Default Location and store your files wherever you like. The name of the project must be unique. The Application Type section lets you select whether you are making an Adobe Integrated Runtime (AIR) application or an application that will run in a browser via the Flash Player plug-in. Finally, the Server Technology settings let you indicate whether the application will be connecting to a server, and if so, what server type and separate configuration type are needed. If you have nothing more to add, click Finish. To change the location where the compiled SWF file will be placed, click Next to reach the screen shown in Figure 1-3. Figure 1-3. Setting the location where the compiled SWF will be placed
  • 25. After the location of the generated SWF has been set, you can either finish or add source folders or SWC files to the project. To add another folder or set of folders, click the Source Path tab (Figure 1-4). To add SWC files to the project, click the Library Path tab (Figure 1-5). On this screen, you can also change the main MXML application file, which is by default the same name as the project. Figure 1-4. Setting the source folder and main application file
  • 26. Figure 1-5. Setting any additional libraries for a Flex project
  • 27. With all paths and names specified, click Finish. Your project is now configured, and you are ready to begin development.
  • 28. Chapter 1. Flex and ActionScript Basics A Flex application consists primarily of code written in two different languages: ActionScript and MXML. Now in its 3.0 incarnation, ActionScript has gone from a prototype-based scripting language to a fully object-oriented, strictly typed, ECMAScript language. MXML is a markup language that will feel comfortable immediately to anyone who has spent time working with Hypertext Markup Language (HTML), Extensible Markup Language (XML), or a host of newer markup-based languages. How do MXML and ActionScript relate to one another? The compiler, after parsing through the different idioms, translates them into the same objects, so that <mx:Button id="btn" label="My Button" height="100"/> and var btn:Button = new Button(); btn.label = "My Button"; btn.height = 100; produce the same object. The major difference is that whereas creating that object in ActionScript (second example) creates the button and nothing else, creating the object in MXML adds the button to whatever component contains the MXML code. The Flex Framework handles calling the constructor of the object described in MXML and either adding it to the parent or setting it as a property of a parent. MXML files can include ActionScript within an <mx:Script> tag, but ActionScript files cannot include MXML. Although it's tempting to think of MXML as the description of the appearance and components that make up your application, and of ActionScript as the description of the event handlers and custom logic your application requires, this is not always true. A far better way to think of their relationship is to understand that both languages ultimately describe the same objects via different syntax. Certain aspects of the Flash platform cannot be accessed without using ActionScript for loops, function declarations, and conditional statements, among many others. This is why the use of ActionScript and the integration between MXML and ActionScript is necessary for all but the very simplest applications. This chapter discusses many aspects of integrating MXML and ActionScript: creating components in MXML, creating classes in ActionScript, adding event listeners, creating code-behind files by using ActionScript and MXML, and creating function declarations. Although it doesn't contain all the answers, it will get you started with the basics of ActionScript and MXML. Recipe 1.1. Create a Flex Project in Flex Builder Recipe 1.1.1. Problem You want to create a project in Flex Builder. Recipe 1.1.2. Solution Use the Create New Project wizard. Recipe 1.1.3. Discussion Flex Builder is built on top of Eclipse, the venerable and well-respected integrated development environment (IDE) most strongly associated with Java development. Although Flex Builder certainly is not necessary for Flex
  • 29. development, it is the premier tool for creating Flex applications and as such provides a wealth of features to help you design and develop applications more effectively. You can use Flex Builder either as a stand-alone application or as a plug-in to an existing installation of Eclipse. The first thing you need to do as a Flex developer is to create a Flex project. A Flex project is different from the other types of projects in Flex Builder because it includes theSWC (Flex library) Flex library SWC (unlike an ActionScript project) and is compiled to a SWF file that can be viewed in the Flash Player (unlike a Flex Library project). To create a project, right-click or Control-click (Mac) in Flex Builder's project navigator to display the contextual menu (Figure 1-1), or use the File menu at the top of the application. From either, choose New Flex Project. A dialog box appears to guide you through creating a project. Figure 1-1. Creating a new Flex project When prompted to specify how the project will get its data, choose Basic, which brings you to the New Flex Project dialog box (Figure 1-2). Figure 1-2. Creating a new project in Flex Builder
  • 30. Enter an application name and below, a location where the files will be stored on your system. The default location is C:/Documents and Settings/Username/Documents/workspace/Projectname on a Windows machine, and Users/Username/Documents/workspace/Projectname on a Mac. You can of course, uncheck Use Default Location and store your files wherever you like. The name of the project must be unique. The Application Type section lets you select whether you are making an Adobe Integrated Runtime (AIR) application or an application that will run in a browser via the Flash Player plug-in. Finally, the Server Technology settings let you indicate whether the application will be connecting to a server, and if so, what server type and separate configuration type are needed. If you have nothing more to add, click Finish. To change the location where the compiled SWF file will be placed, click Next to reach the screen shown in Figure 1-3. Figure 1-3. Setting the location where the compiled SWF will be placed
  • 31. After the location of the generated SWF has been set, you can either finish or add source folders or SWC files to the project. To add another folder or set of folders, click the Source Path tab (Figure 1-4). To add SWC files to the project, click the Library Path tab (Figure 1-5). On this screen, you can also change the main MXML application file, which is by default the same name as the project. Figure 1-4. Setting the source folder and main application file
  • 32. Figure 1-5. Setting any additional libraries for a Flex project
  • 33. With all paths and names specified, click Finish. Your project is now configured, and you are ready to begin development.
  • 34. Recipe 1.2. Create a Flex Library Project in Flex Builder Recipe 1.2.1. Problem You need to create a Flex Library project. Recipe 1.2.2. Solution From the Flex Navigator, choose New Flex Library Project to access the Create New Project wizard. Recipe 1.2.3. Discussion A Flex Library project does not have a main MXML file that it is compiled into a SWF. Instead the files are compiled into a SWC file that can be used in other applications or as the source for a runtime shared library (usually referred to as an RSL). The classes within the library are used to create a group of assets that can be reused in multiple projects at either compile time or runtime. To create a Flex Library project, right-click or Control-click (Mac) in the Flex Builder's project navigator to open the contextual menu (Figure 1-6) or use the File menu. In either case, then choose New Flex Library Project. Figure 1-6. Creating a Flex Library project
  • 35. In the resulting dialog box (Figure 1-7), specify a name for your project as well as its location. Figure 1-7. Setting the project location and SDK for the compiler
  • 36. If you have nothing more to add, click Finish now. If you need to include files, assets, or other SWC files, including the Adobe AIR libraries, click Next and select them from the resulting screen. To set classes that can be selected and added into the recipe, first browse to a source path you would like to include and then set either classes or graphical assets that will be compiled into the library. Click Finish to create the project.
  • 37. Recipe 1.3. Create an ActionScript Project Recipe 1.3.1. Problem You want to create an ActionScript project that does not use the Flex 3 libraries. Recipe 1.3.2. Solution Use the Create New Project wizard and select ActionScript Project. Recipe 1.3.3. Discussion An ActionScript project is different from a Flex project in that it does not include the Flex Framework at all. ActionScript projects rely on the core ActionScript classes within the Flash code base and do not have access to any of the components in the Flex Framework. To create an ActionScript project, choose File New ActionScript Project (Figure 1-8). Figure 1-8. Creating an ActionScript project
  • 38. In the resulting dialog box, specify a name for the project and a location where the files and compiled SWFs will reside. Click Finish to finalize the project with default settings, or click Next to add libraries or other source folders to the project, change the main file of the application, add SWC files that your code can access, or change the location of the output SWF. By default, the name of the main ActionScript file for the application will be set as the name of the project. The default output location of the SWF file will be the bin-debug folder in the project.
  • 39. Recipe 1.4. Set Compiler Options for the MXML Compiler in Flex Builder Recipe 1.4.1. Problem You need to set specific compiler options for the MXML compiler. Recipe 1.4.2. Solution Set the options for the compiler arguments in the Flex Compiler screen of the Project Properties dialog box. Recipe 1.4.3. Discussion The MXML compiler, also called the mxmlc, is the application that compiles ActionScript and MXML files into a SWF file that can be viewed in the Flash Player. When you run or debug a Flex application in Flex Builder, the MXML compiler is invoked and the files are passed to the compiler as an argument to the application. When you debug the player, an argument to create a debug SWF is passed to the MXML compiler. Flex Builder lets you pass other arguments to the MXML compiler, as well; for example, you can pass arguments to specify the location of an external library path, allow the SWF to access local files, or set the color of the background. To change the compiler settings for a project, right-click or Control-click (Mac) on the project and select Properties from the contextual menu (Figure 1-9), or choose Project Properties from the menu bar. Figure 1-9. Changing the properties of a project
  • 40. In the resulting Project Properties dialog box (Figure 1-10), select Flex Compiler. Here you have several options to control how the SWF file is compiled. In the input field labeled Additional Compiler Arguments, you can add multiple options; simply type a hyphen (-) in front of each option and separate the options with spaces.
  • 41. Figure 1-10. Setting compiler options Some of the most commonly used options are as follows: verbose-stacktraces Specifies whether the SWF will include line numbers and filenames when a runtime error occurs. This makes the generated SWF larger, and a SWF with verbose-stacktraces is different than a debug SWF. source-path path-element Adds any directories or files to the source path to have any MXML or ActionScript files be included. You can use wildcards to include all files and subdirectories of a directory. Also you can use += to append the new argument to the default options or any options set in a configuration file, for example: -source-path+=/Users/base/Project include-libraries
  • 42. Specifies a SWC file to be compiled into the application and links all the classes and assets in the library into the SWF. This option is useful if the application will load in other modules that may need access to the classes in a SWC that the SWF will not be using. library-path Similar to the include-libraries option but includes only classes and assets that are used in the SWF. This lets you keep the size of the SWF file manageable. locale Specifies a locale to be associated with a SWF file. For example, use -locale=es_ES to specify that the SWF is localized for Spanish. use-network Indicates whether the SWF will have access to the local file system and is intended for use on a local machine, or whether the standard Flash Player security will apply. For example, use -use-network=false to specify that the SWF will have local file system access but will not be able to use any network services. The default value is true. frames.frame Enables you to add asset factories that stream in after the application and then publish their interfaces with the ModuleManager class. The advantage of doing this is that the application starts faster than it would have if the assets had been included in the code, but does not require moving the assets to an external SWF file. One of the more difficult and more useful parameters. keep-all-type-selectors Ensures that all style information, even if it is not used in the application, is compiled into the SWF. This is important if the application will be loading other components that require style information. The default value is false, which means that style information not used in the application is not compiled into the SWF. After setting the options for the compiler, click the Apply button to save the options for that project.
  • 43. Recipe 1.5. Compile a Flex Project Outside of Flex Builder Recipe 1.5.1. Problem You are not using Flex Builder for your Flex project and need to compile your project. Recipe 1.5.2. Solution Use a terminal or command prompt to invoke the MXML compiler. Recipe 1.5.3. Discussion Although Flex Builder is a powerful tool for Flex development, it is certainly not necessary for creating Flex applications. The MXML compiler (mxmlc) is free to anyone and can be downloaded from Adobe. To compile a Flex application outside of Flex Builder, open a command prompt (Windows) or a terminal (Mac OS X), invoke the MXML compiler, and pass the file containing the application as an argument, using a command such as the following: Code View: home:base$ . /Users/base/Flex SDK 3/bin/mxmlc ~/Documents/FlexTest/FlexTest.mxml This will compile the MXML file into a SWF that by default compiles into the folder where the MXML file is located. Any warnings or errors from the compiler will be displayed in the terminal or command-prompt window. To add further options to the MXML compiler, you append arguments to the call to the compiler. For example: Code View: home:base$ ./mxmlc ~/Documents/FlexTest/FlexTest.mxml -output=/Users/base/test/genera ted/Index.swf -library-path+=/Users/lib/MyLib.swc generates a SWF file named Index.swf, places it in the directory at /Users/base/test/generated/, and includes the SWC library /Users/lib/MyLib.swc. To invoke the MXML compiler directly from the command line without providing the full path to your SDK installation (which in this example is C:flex_sdk_3), you will need to add the /bin directory the compiler resides in to the Path systems variable. On Windows: Open System from the Control Panel. 1. Select the Advanced tab. 2. 3.
  • 44. 2. Click Environment Variables. 3. Within the System variables grid, navigate to and double-click Path. 4. In the Variable Value field, if the last character is not set to a semicolon (;), enter a semicolon and then the path to the /bin folder within your Flex SDK installation directory (Figure 1-11). Figure 1-11. Setting the Flex SDK 3 Path variable 5. 6.
  • 45. With the path to the MXML compiler directory set, open a command prompt, navigate to your project directory, and enter the following command: C:DocumentsFlexTest> mxmlc FlexTest.mxml This generates the FlexTest.swf file within C:DocumentsFlexTest, just as the first command presented in this section does. Setting the path to the /bin directory of the Flex 3 SDK installation lets you invoke the compiler from any directory including, in this example, your current project directory. 6. If step 6 results in the following error message Error: could not find JVM you must manually enter the path to the directory in which the Java Runtime Environment (JRE) is installed on your machine. To manually enter the path, navigate to the /bin directory of your Flex 3 SDK installation. Open the jvm.config file in a text editor, and append the path to your JRE installation directory to the variable java.home. Assuming the Java installation is on the root of your drive, you enter the following: java.home=C:/Java/jre 7. On Mac OS X or Linux: Open your .bash_profile file (if you are using Bash) and edit the path variable by adding the location of the MXML compiler. Your .bash_profile file should look something like this: PATH="${PATH}:~/flex3SDK/bin" export PATH The .bash_profile will be located in your user home directory (which you can always access via a command line by typing cd ~). If you are using tsch, the path to the MXML compiler should be added to the .profile file. 1. If the Java runtime is not set properly, set the following path variable in your terminal shell: PATH="${PATH}:~/flex3SDK/bin" export PATH 2.
  • 46. Exploring the Variety of Random Documents with Different Content
  • 47. Gutenberg™’s goals and ensuring that the Project Gutenberg™ collection will remain freely available for generations to come. In 2001, the Project Gutenberg Literary Archive Foundation was created to provide a secure and permanent future for Project Gutenberg™ and future generations. To learn more about the Project Gutenberg Literary Archive Foundation and how your efforts and donations can help, see Sections 3 and 4 and the Foundation information page at www.gutenberg.org. Section 3. Information about the Project Gutenberg Literary Archive Foundation The Project Gutenberg Literary Archive Foundation is a non- profit 501(c)(3) educational corporation organized under the laws of the state of Mississippi and granted tax exempt status by the Internal Revenue Service. The Foundation’s EIN or federal tax identification number is 64-6221541. Contributions to the Project Gutenberg Literary Archive Foundation are tax deductible to the full extent permitted by U.S. federal laws and your state’s laws. The Foundation’s business office is located at 809 North 1500 West, Salt Lake City, UT 84116, (801) 596-1887. Email contact links and up to date contact information can be found at the Foundation’s website and official page at www.gutenberg.org/contact Section 4. Information about Donations to the Project Gutenberg Literary Archive Foundation Project Gutenberg™ depends upon and cannot survive without widespread public support and donations to carry out its mission of increasing the number of public domain and licensed works that can be freely distributed in machine-readable form
  • 48. accessible by the widest array of equipment including outdated equipment. Many small donations ($1 to $5,000) are particularly important to maintaining tax exempt status with the IRS. The Foundation is committed to complying with the laws regulating charities and charitable donations in all 50 states of the United States. Compliance requirements are not uniform and it takes a considerable effort, much paperwork and many fees to meet and keep up with these requirements. We do not solicit donations in locations where we have not received written confirmation of compliance. To SEND DONATIONS or determine the status of compliance for any particular state visit www.gutenberg.org/donate. While we cannot and do not solicit contributions from states where we have not met the solicitation requirements, we know of no prohibition against accepting unsolicited donations from donors in such states who approach us with offers to donate. International donations are gratefully accepted, but we cannot make any statements concerning tax treatment of donations received from outside the United States. U.S. laws alone swamp our small staff. Please check the Project Gutenberg web pages for current donation methods and addresses. Donations are accepted in a number of other ways including checks, online payments and credit card donations. To donate, please visit: www.gutenberg.org/donate. Section 5. General Information About Project Gutenberg™ electronic works Professor Michael S. Hart was the originator of the Project Gutenberg™ concept of a library of electronic works that could be freely shared with anyone. For forty years, he produced and
  • 49. distributed Project Gutenberg™ eBooks with only a loose network of volunteer support. Project Gutenberg™ eBooks are often created from several printed editions, all of which are confirmed as not protected by copyright in the U.S. unless a copyright notice is included. Thus, we do not necessarily keep eBooks in compliance with any particular paper edition. Most people start at our website which has the main PG search facility: www.gutenberg.org. This website includes information about Project Gutenberg™, including how to make donations to the Project Gutenberg Literary Archive Foundation, how to help produce our new eBooks, and how to subscribe to our email newsletter to hear about new eBooks.
  • 50. Welcome to our website – the ideal destination for book lovers and knowledge seekers. With a mission to inspire endlessly, we offer a vast collection of books, ranging from classic literary works to specialized publications, self-development books, and children's literature. Each book is a new journey of discovery, expanding knowledge and enriching the soul of the reade Our website is not just a platform for buying books, but a bridge connecting readers to the timeless values of culture and wisdom. With an elegant, user-friendly interface and an intelligent search system, we are committed to providing a quick and convenient shopping experience. Additionally, our special promotions and home delivery services ensure that you save time and fully enjoy the joy of reading. Let us accompany you on the journey of exploring knowledge and personal growth! ebookfinal.com