"Flex 3 Beta 1
™
Adobe Flex 3
®
Developer’sGuide
Flex 3 Beta 1
© 2007 Adobe Systems Incorporated. All rights reserved. Flex™ Developer’s Guide If this guide is distributed with software that includes an end-user agreement, this guide, as well as the software described in it, is furnished under license and may be used or copied only in accordance with the terms of such license. Except as permitted by any such license, no part of this guide may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, recording, or otherwise, without the prior written permission of Adobe Systems Incorporated. Please note that the content in this guide is protected under copyright law even if it is not distributed with software that includes an end-user license agreement. The content of this guide is furnished for informational use only, is subject to change without notice, and should not be construed as a commitment by Adobe Systems Incorporated. Adobe Systems Incorporated assumes no responsibility or liability for any errors or inaccuracies that may appear in the informational content contained in this guide. Please remember that existing artwork or images that you may want to include in your project may be protected under copyright law. The unauthorized incorporation of such material into your new work could be a violation of the rights of the copyright owner. Please be sure to obtain any permission required from the copyright owner. Any references to company names in sample templates are for demonstration purposes only and are not intended to refer to any actual organization. Adobe, the Adobe logo, Flex, Flex Builder and Flash Player are either registered trademarks or trademarks of Adobe Systems Incorporated in the United States and/or other countries. ActiveX and Windows are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries. Linux is a registered trademark of Linus Torvalds. Solaris is a registered trademark or trademark of Sun Microsystems, Inc. in the United States and other countries. All other trademarks are the property of their respective owners. This product includes software developed by the Apache Software Foundation (http://www.apache.org/). Macromedia Flash 8 video is powered by On2 TrueMotion video technology. © 1992-2005 On2 Technologies, Inc. All Rights Reserved. http:// www.on2.com. This product includes software developed by the OpenSymphony Group (http://www.opensymphony.com/). Portions licensed from Nellymoser (www.nellymoser.com). Portions utilize Microsoft Windows Media Technologies. Copyright (c) 1999-2002 Microsoft Corporation. All Rights Reserved. Includes DVD creation technology used under license from Sonic Solutions. Copyright 1996-2005 Sonic Solutions. All Rights Reserved. This Product includes code licensed from RSA Data Security. Portions copyright Right Hemisphere, Inc. This product includes software developed by the OpenSymphony Group (http://www.opensymphony.com/). Sorenson™ Spark™ video compression and decompression technology licensed from Sorenson Media, Inc. Adobe Systems Incorporated, 345 Park Avenue, San Jose, California 95110, USA Notice to U.S. government end users. The software and documentation are “Commercial Items,” as that term is defined at 48 C.F.R. §2.101, consisting of “Commercial Computer Software” and “Commercial Computer Software Documentation,” as such terms are used in 48 C.F.R. §12.212 or 48 C.F.R. §227.7202, as applicable. Consistent with 48 C.F.R. §12.212 or 48 C.F.R. §§227.7202-1 through 227.7202-4, as applicable, the Commercial Computer Software and Commercial Computer Software Documentation are being licensed to U.S. Government end users (a) only as Commercial items and (b) with only those rights as are granted to all other end users pursuant to the terms and conditions herein. Unpublished-rights reserved under the copyright laws of the United States. Adobe Systems Incorporated, 345 Park Avenue, San Jose, CA 95110-2704, USA. For U.S. Government End Users, Adobe agrees to comply with all applicable equal opportunity laws including, if appropriate, the provisions of Executive Order 11246, as amended, Section 402 of the Vietnam Era Veterans Readjustment Assistance Act of 1974 (38 USC 4212), and Section 503 of the Rehabilitation Act of 1973, as amended, and the regulations at 41 CFR Parts 60-1 through 60-60, 60-250 ,and 60-741. The affirmative action clause and regulations contained in the preceding sentence shall be incorporated by reference. Part Number: 90070488 (12/06)
Flex 3 Beta 1
Contents
Chapter 1: About Flex Documentation . . . . . . . . . . . . . . . . . . . . . . 15
PART 1: USING FLEX PROGRAMMING LANGUAGES Chapter 2: Developing Applications in MXML . . . . . . . . . . . . . . . 21 About MXML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 Developing applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 Chapter 3: MXML Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 Basic MXML syntax. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 Setting component properties. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 Chapter 4: Using ActionScript . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 Using ActionScript in Flex applications. . . . . . . . . . . . . . . . . . . . . . . . . . 55 Working with Flex components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 Comparing, including, and importing ActionScript code . . . . . . . . . . . 68 Techniques for separating ActionScript from MXML . . . . . . . . . . . . . .72 Creating ActionScript components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .75 Performing object introspection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 Chapter 5: Using Events. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .83 About events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83 Using events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .87 Manually dispatching events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 Event propagation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115 Event priorities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .122 Using event subclasses. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .124 About keyboard events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126 Chapter 6: About Flex Data Access . . . . . . . . . . . . . . . . . . . . . . . 133 About data access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133 Comparing Flex data access to other technologies . . . . . . . . . . . . . . . 137
iii
Flex 3 Beta 1
PART 2: BUILDING USER INTERFACES FOR FLEX APPLICATIONS Chapter 7: Using Flex Visual Components . . . . . . . . . . . . . . . . . 143 About visual components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143 Class hierarchy for visual components . . . . . . . . . . . . . . . . . . . . . . . . . . 144 Using the UIComponent class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145 Sizing visual components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .151 Handling events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156 Using styles. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161 Using behaviors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163 Applying skins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165 Changing the appearance of a component at run time . . . . . . . . . . . . 165 Extending components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168 Chapter 8: Using Data Providers and Collections . . . . . . . . . . . .171 About data providers and collections . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171 Using IList interface methods and properties . . . . . . . . . . . . . . . . . . . . 184 Using ICollectionView interface methods and properties. . . . . . . . . . 186 Using events and update notifications . . . . . . . . . . . . . . . . . . . . . . . . . . 199 Using hierarchical data providers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .207 Using remote data providers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .223 Chapter 9: Sizing and Positioning Components . . . . . . . . . . . . 225 About sizing and positioning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .225 Sizing components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .232 Positioning and laying out controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . .252 Constraint-based layout. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259 Chapter 10: Using Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .267 About controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .268 Working with controls. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274 Button control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277 PopUpButton control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281 ButtonBar and ToggleButtonBar controls . . . . . . . . . . . . . . . . . . . . . .284 LinkBar control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .288 TabBar control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291 CheckBox control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295 RadioButton control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .296 NumericStepper control. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302 DateChooser and DateField controls . . . . . . . . . . . . . . . . . . . . . . . . . . 304
iv
Flex 3 Beta 1
LinkButton control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 316 HSlider and VSlider controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .319 SWFLoader control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328 Image control. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 334 VideoDisplay control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 344 ColorPicker control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .351 Alert control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 360 ProgressBar control. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365 HRule and VRule controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 370 ScrollBar control. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 374 Chapter 11: Using Text Controls. . . . . . . . . . . . . . . . . . . . . . . . . . .377 About text controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 377 Using the text property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 379 Using the htmlText property. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 384 Selecting and modifying text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 395 Label control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 400 TextInput control. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .401 Text control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403 TextArea control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 405 RichTextEditor control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 406 Chapter 12: Using Menu-Based Controls. . . . . . . . . . . . . . . . . . . 415 About menu-based controls. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .415 Defining menu structure and data. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .416 Handling menu-based control events . . . . . . . . . . . . . . . . . . . . . . . . . . 423 Menu control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 435 MenuBar control. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 439 PopUpMenuButton control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .441 Chapter 13: Using Data-Driven Controls . . . . . . . . . . . . . . . . . . 447 List control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . HorizontalList control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . TileList control. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ComboBox control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . DataGrid control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Tree control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 448 458 462 466 475 487
Chapter 14: Using the AdvancedDataGrid Control . . . . . . . . . . .501 About the AdvancedDataGrid control . . . . . . . . . . . . . . . . . . . . . . . . . . 502 Sorting by multiple columns. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 504
v
Flex 3 Beta 1
Styling rows and columns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 506 Selecting multiple cells and rows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 513 Hierarchical and grouped data display . . . . . . . . . . . . . . . . . . . . . . . . . . 517 Displaying hierarchical data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .525 Displaying grouped data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 529 Creating column groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 544 Using item renderers with the AdvancedDataGrid control. . . . . . . . 550 Keyboard navigation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 560 Chapter 15: Introducing Containers . . . . . . . . . . . . . . . . . . . . . . 563 About containers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .563 Using containers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .565 Using scroll bars. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 579 Using Flex coordinates. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .582 Creating and managing component instances at run time . . . . . . . . .588 Chapter 16: Using the Application Container . . . . . . . . . . . . . . . 601 Using the Application container . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 601 About the Application object. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 609 Showing the download progress of an application . . . . . . . . . . . . . . . 614 Chapter 17: Using Layout Containers . . . . . . . . . . . . . . . . . . . . . 625 About layout containers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .626 Canvas layout container. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .626 Box, HBox, and VBox layout containers . . . . . . . . . . . . . . . . . . . . . . . . 631 ControlBar layout container . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .634 ApplicationControlBar layout container . . . . . . . . . . . . . . . . . . . . . . . . .636 DividedBox, HDividedBox, and VDividedBox layout containers . . .639 Form, FormHeading, and FormItem layout containers . . . . . . . . . . . .642 Grid layout container. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .666 Panel layout container . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 673 Tile layout container . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 678 TitleWindow layout container . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 681 Chapter 18: Using Navigator Containers . . . . . . . . . . . . . . . . . . 699 About navigator containers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 699 ViewStack navigator container. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .700 TabNavigator container . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .706 Accordion navigator container . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 710
vi
Flex 3 Beta 1
PART 3: CUSTOMIZING THE USER INTERFACE Chapter 19: Using Behaviors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 719 About behaviors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 719 Applying behaviors. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 729 Working with effects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 744 Chapter 20: Using Styles and Themes. . . . . . . . . . . . . . . . . . . . .767 About styles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 767 Using external style sheets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 796 Using local style definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 797 Using the StyleManager class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 800 Using the setStyle() and getStyle() methods . . . . . . . . . . . . . . . . . . . . 807 Using inline styles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 812 Loading style sheets at run time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .814 Using filters in Flex . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 823 About themes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 828 Chapter 21: Using Fonts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 835 About fonts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Using device fonts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Using embedded fonts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Using multiple typefaces. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . About the font managers . . . . . . . . . . . ...."
|
You need to upgrade your Flash Player , or try to enable javascript in order see this document properly.
|
|