Flex is a very powerful and versatile technology for creating web application front-ends. But what every good web application needs is a robust data source, be it XML, or a database. Flex is very adaptable in terms of connecting to data sources, and that is the main focus of this book. In Foundation Flex for Developers, author Sas Jacobs assumes that you've got the basics of Flex down already, and explores in detail how to create professional data-centric Flex 2 and Flex 3 applications. In the first half of the book, she starts off with a brief exploration of Flex and ActionScript 3.0, before looking at application essentials in detail—creating custom components, user and web browser interactions, binding, formatting, and validating data, debugging, and more. In the second half of the book, the focus is on connecting Flex to data sources, and covers XML, LiveCycle Data Services, PHP, ASP.NET, and ColdFusion in detail, via a series of step-by-step case studies. Covers Flex application basics Covers connecting Flex 2 and Flex 3 to a variety of Data Sources Includes several complete case studies What you’ll learn How to create custom components How to handle user and web browser interactions How to debug Flex 2 applications How to bind, format, and validate data How to load and write external content The essentials of XML, and working with it in Flex 2, including E4X The essentials of Flex Data Services How to build up data-driven Flex 2 applications with PHP, ASP.NET, and ColdFusion backends Who this book is for This book is for any Flex developer who knows the basics of building Flex user interfaces, and wants to learn how to connect their applications to data sources.
Author(s): Sas Jacobs
Edition: 1
Publisher: friendsofED
Year: 2007
Language: English
Pages: 574
Foundation Flex for Developers......Page 0
CONTENTS AT A GLANCE......Page 6
CONTENTS......Page 8
ABOUT THE AUTHORS......Page 20
ABOUT THE TECHNICAL REVIEWER......Page 22
ABOUT THE COVER IMAGE DESIGNER......Page 24
ACKNOWLEDGMENTS......Page 26
INTRODUCTION......Page 28
FLEX APPLICATION BASICS......Page 30
INTRODUCTION TO FLEX......Page 32
Understanding web applications......Page 33
Understanding the role of Flex......Page 34
Understanding the role of MXML and ActionScript 3.0......Page 35
Understanding MXML......Page 36
Understanding ActionScript 3.0......Page 37
Understanding the major changes in ActionScript 3.0......Page 38
Working with applications in Flex......Page 40
Flex tools for working with data......Page 41
Useful resources......Page 42
Summary......Page 43
WORKING WITH ACTIONSCRIPT 3.0 IN FLEX 3......Page 46
Working with ActionScript 3.0 in Flex applications......Page 47
Using inline ActionScript statements......Page 48
Using the element......Page 51
Using include inside an element......Page 56
Creating custom class files......Page 57
Creating ActionScript projects......Page 65
Working with a minimal Flex interface......Page 66
Understanding ActionScript 3.0 events......Page 69
What happened to trace?......Page 71
Importing classes......Page 72
Summary......Page 73
CREATING CUSTOM COMPONENTS......Page 76
Creating components using MXML......Page 77
Example: Creating a country ComboBox component......Page 78
Passing a value to the component......Page 80
Binding a property in the component......Page 83
Dispatching events......Page 84
Creating a custom event class......Page 85
Creating a composite component......Page 88
Working through examples......Page 92
Passing values to ActionScript components......Page 94
Dispatching custom events in ActionScript components......Page 95
Deciding on MXML or ActionScript......Page 96
Using the code-behind approach......Page 97
Sharing components......Page 98
Distributing SWC files......Page 99
Using SWC files......Page 100
Summary......Page 101
INTERACTING WITH USERS......Page 104
Adding a message and title......Page 105
Adding a closeHandler method......Page 106
A simple example......Page 107
Changing the appearance of the alert......Page 111
Working with pop-ups......Page 113
A simple example......Page 114
Passing values from the pop-up......Page 118
Passing values to the pop-up......Page 121
Responding to pop-up events......Page 122
Understanding the Form container......Page 125
Working with a data model......Page 126
Determining required values......Page 130
Validating user input......Page 131
Working with the DateValidator......Page 133
Working with the NumberValidator......Page 134
Working with the StringValidator......Page 135
Adding validation to a form......Page 136
Validating with validator events......Page 138
Validating with ActionScript......Page 139
Using the DateFormatter......Page 142
Using the PhoneFormatter......Page 143
Applying the formatter......Page 144
Adding formatters to a form......Page 145
Summary......Page 146
INTERACTING WITH THE WEB BROWSER......Page 148
Loading a web page from Flex......Page 149
Calling JavaScript with navigateToURL......Page 150
Working through a simple example......Page 151
Sending variables into a SWF file......Page 153
Using querystring parameters......Page 154
Using flashVars......Page 157
Understanding the External API......Page 159
Calling a JavaScript function using ActionScript......Page 160
Calling an ActionScript function with JavaScript......Page 164
Working through a two-way communication example......Page 168
Limitations of the External API......Page 172
Understanding Flash Player security......Page 173
Summary......Page 174
WORKING WITH DATA IN FLEX APPLICATIONS......Page 176
Working with the HTTPService class......Page 177
Receiving a response......Page 178
Accessing loaded content......Page 179
Properties of the HTTPService class......Page 180
Understanding the URLLoader class......Page 182
Specifying a return type......Page 183
Methods of the URLLoader class......Page 184
Comparing the HTTPService and URLLoader......Page 185
Using the tag......Page 186
Using the HTTPService class with ActionScript......Page 188
Using the URLLoader class......Page 189
Using variable pairs with the HTTPService class......Page 190
Using the tag......Page 191
Using the HTTPService class with ActionScript......Page 193
Using the URLLoader class......Page 194
Sending variables with the URLLoader......Page 195
Updating content with the HTTPService class......Page 196
Updating content with the URLLoader class......Page 201
Understanding security sandboxes......Page 203
Proxying data locally......Page 204
Separating data from presentation......Page 205
Working with the tag......Page 206
Using ActionScript to work with complex data structures......Page 208
Understanding data binding......Page 216
Binding with curly braces syntax......Page 217
Binding with the tag......Page 218
Binding with ActionScript......Page 224
Working through a scripted binding example......Page 227
Understanding validators......Page 230
Understanding formatters......Page 233
Summary......Page 236
INTRODUCTION TO XML......Page 238
Understanding the XML framework......Page 239
A brief history......Page 240
Understanding why you should use XML......Page 241
Using XML information......Page 242
The document prolog......Page 243
The document tree......Page 245
Namespaces......Page 249
A simple MXML document......Page 250
Element structure......Page 251
Elements must nest correctly......Page 252
Summary......Page 253
USING XML IN FLEX BUILDER......Page 256
Understanding E4X expressions......Page 257
Understanding the XML and XMLList classes......Page 260
Manipulating XML content......Page 265
Working with the tag......Page 267
Using the tag......Page 269
Using the HTTPService class with ActionScript......Page 271
Using the URLLoader class......Page 272
Binding XML content with E4X expressions......Page 273
Working through an example......Page 274
Working with the WebService class......Page 282
Consuming a web service with the tag......Page 288
Consuming a web service with ActionScript......Page 292
Summary......Page 294
FLEX DATA-DRIVEN CONTROLS......Page 296
Working with a dataProvider......Page 297
Setting the dataProvider......Page 298
Using XML as a dataProvider......Page 299
Iterating through controls in a Repeater......Page 300
Working through a simple example......Page 301
Displaying images in a TileList......Page 305
Changing the direction......Page 307
Using a custom item renderer......Page 308
Working through an example......Page 310
Using the DataGrid......Page 313
Specifying column settings......Page 314
Reordering columns......Page 316
Setting the display of data within a column......Page 317
Using renderers......Page 318
Editing content......Page 322
Working with rows......Page 326
Using common DataGrid events......Page 327
Working through a DataGrid example......Page 330
Summary......Page 338
DEBUGGING FLEX APPLICATIONS......Page 340
Working with the trace method......Page 341
Logging to a text file......Page 342
Working with the tag......Page 343
Compiler warning messages......Page 344
Compiler errors......Page 345
Run-time errors......Page 346
Using ActionScript to catch run-time errors......Page 347
Using the debugger......Page 352
Adding breakpoints......Page 354
Viewing variable values......Page 355
Changing the value of a variable......Page 357
Watching a variable......Page 358
Summary......Page 359
PART 2 DATA-DRIVEN APPLICATIONS......Page 360
XML CASE STUDY......Page 362
The application interface......Page 363
Structuring the application......Page 365
Creating the interface......Page 366
Creating the custom class......Page 367
Writing the custom class......Page 368
Creating the constructor method......Page 369
Loading the XML document......Page 370
Creating the GalleryLoader object......Page 371
Processing the loaded XML content......Page 372
Populating the ComboBox with galleries......Page 374
Creating the interface......Page 375
Configuring the component......Page 376
Displaying the first image......Page 378
Displaying the other images......Page 381
Summary......Page 384
COLDFUSION PROJECT......Page 386
Understanding the application......Page 387
The application data source......Page 389
Connecting to the ColdFusion server......Page 390
Creating the ColdFusion page......Page 393
Creating the Flex application......Page 395
Creating the Flex interface......Page 396
Summary......Page 402
ASP.NET CASE STUDY......Page 404
The application interface......Page 405
The application data source......Page 407
Structuring the application......Page 410
Creating the application......Page 412
Creating the Flex application interface......Page 413
Creating the ASP.NET pages to generate XML content for the application......Page 415
Creating the custom class......Page 420
Loading the events for a specific date......Page 422
Populating the interface with the events......Page 424
Creating a custom component for event details......Page 428
Showing details of the selected event......Page 435
Updating the selected event......Page 436
Adding a new event......Page 444
Deleting an event......Page 445
Summary......Page 448
PHP CASE STUDY......Page 450
The application interface......Page 451
The application data source......Page 455
Structuring the application......Page 457
Creating the application......Page 458
Creating the Flex application interface......Page 459
Creating the PHP pages to generate the XML content......Page 462
Creating the custom ActionScript class to load the content......Page 465
Loading the XML content......Page 467
Creating custom events......Page 468
Displaying the current posts......Page 471
Displaying the archive posts......Page 474
Coding the login form......Page 477
Creating a custom component for post details......Page 481
Updating the selected post......Page 483
Adding a new post......Page 492
Deleting an existing post......Page 493
Summary......Page 495
LIVECYCLE DATA SERVICES......Page 496
INTRODUCTION TO LIVECYCLE DATA SERVICES......Page 498
LiveCycle Data Services features......Page 499
Installing LiveCycle Data Services ES......Page 500
Set up a Flex application for use with LiveCycle Data Services ES......Page 503
Using LiveCycle Data Services......Page 504
Building a basic chat application......Page 505
Exploring web and HTTP services......Page 510
Exploring the remote object service......Page 518
Data Management Services......Page 526
Using DMS with SQLAssembler......Page 528
Summary......Page 538
LIVECYCLE DATA SERVICES CASE STUDY......Page 540
The book admin application......Page 541
The book viewer application......Page 542
The server-side configuration......Page 543
Creating the book admin application......Page 545
Showing the selected book details......Page 546
Updating the selected book details......Page 550
Deleting a Book object......Page 551
Uploading a book cover to the server......Page 552
Adding an application ControlBar......Page 557
Setting up the Flex DataService......Page 558
Building the custom item renderer......Page 559
Showing the books in a TileList......Page 560
Showing the details of each book......Page 561
Summary......Page 562
INDEX......Page 564