Tải bản đầy đủ

Flex 4 in action

Revised edition of Flex 3 in Action

IN ACTION
Tariq Ahmed
Dan Orlando
WITH John C. Bland II
AND Joel Hooks

MANNING
www.it-ebooks.info


Praise for Flex 3 in Action
The code examples are the strength of this book—plentiful for almost every topic covered.
—Andrew Grother, Triware Technologies, Inc.
Easy enough for the newbie, detailed enough for the veteran.
—Ken Brueck, Move Network
This is a book you will not only want to read cover to cover but also keep on your desk
as a reference for your day to day development needs.
—Abdul Qabiz, reader
Does a great job of covering some of the history behind traditional web development and

where Rich Internet Applications are headed.
—Sami Hoda, eCivis Inc.
A user-friendly tutorial and reference.
—Christophe Bunn, Kitry S.A.S.
An impressive amount of Flex content in a single volume.
—Charlie Griefer, Amcom Technology
It’s clear that the authors put a lot of time and effort into the book. The fact that it comes
with an ebook for this version and the future Flex 4 in Action is a nice bonus.
—A. Kapadia, Amazon reader
I’m a huge fan of Manning’s In Action series. This series caters to people who want
more than a quick gloss-over…. Flex 3 in Action is a roll up your sleeves and get busy
kind of book that makes it easy to get into Flex.
—Allan Mercado, Amazon reader

www.it-ebooks.info


www.it-ebooks.info


Flex 4 in Action
REVISED EDITION OF FLEX 3 IN ACTION
TARIQ AHMED
DAN ORLANDO
with JOHN C. BLAND II
and JOEL HOOKS

MANNING
Greenwich
(74° w. long.)

www.it-ebooks.info


For online information and ordering of this and other Manning books, please visit
www.manning.com. The publisher offers discounts on this book when ordered in quantity.
For more information, please contact
Special Sales Department
Manning Publications Co.
180 Broad St.


Suite 1323
Stamford, CT 06901
Email: orders@manning.com

©2011 by Manning Publications Co. All rights reserved.

No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in
any form or by means electronic, mechanical, photocopying, or otherwise, without prior written
permission of the publisher.

Many of the designations used by manufacturers and sellers to distinguish their products are
claimed as trademarks. Where those designations appear in the book, and Manning
Publications was aware of a trademark claim, the designations have been printed in initial caps
or all caps.

Recognizing the importance of preserving what has been written, it is Manning’s policy to have
the books we publish printed on acid-free paper, and we exert our best efforts to that end.
Recognizing also our responsibility to conserve the resources of our planet, Manning books
are printed on paper that is at least 15 percent recycled and processed without the use of
elemental chlorine.

Manning Publications Co.
180 Broad St.
Suite 1323
Stamford, CT 06901

Development editor:
Copyeditor:
Proofreader:
Typesetter:
Cover designer:

Cynthia Kane
Linda Recktenwald
Maureen Spencer
Dottie Marsico
Marija Tudor

ISBN 978-1-935182-42-9
Printed in the United States of America
1 2 3 4 5 6 7 8 9 10 – MAL – 15 14 13 12 11 10

www.it-ebooks.info


brief contents
PART 1 APPLICATION BASICS .....................................................1
1



Making the case 3

2



Getting started 21

3



Working with ActionScript 44

4



Layout and containers

5



Displaying forms and capturing user input

6



Validating user input

7



Formatting data

8



MX DataGrids, Lists, and Trees

9



Using the Spark List controls

10



List customization

70
96

117

138
155
178

192

PART 2 APPLICATION FLOW AND STRUCTURE . ........................219
11



Events

12



221

Application navigation

13



Introduction to pop-ups

14



Implementing view states

15



Working with data services

244
273
294
316

v

www.it-ebooks.info


vi

BRIEF CONTENTS

16



17



Objects and classes 341
Custom components 358

18



Creating reusable components

19



Architectural design patterns 405

388

PART 3 THE FINISHING TOUCHES...........................................441
20



Customizing the experience 443

21



Working with effects

22



Drag-and-drop 502

23



Exploring Flex charting

24



Debugging and testing

557

25



Wrapping up a project

579

469
530

www.it-ebooks.info


contents
foreword to the first edition xx
preface xxii
acknowledgments xxv
about this book xxvii
about the title xxxii
about the cover illustration xxxiii

PART 1 APPLICATION BASICS ........................................... 1

1

Making the case
1.1
1.2

3

Why are web applications so prolific? 3
The RIA solution 5
They all want it all 5
How RIAs do it 6

1.3

The RIA contenders
Flex by Adobe 7
Microsystems 8

1.4






RIAs to the rescue

5

7

Silverlight by Microsoft 8
AJAX—the last stand 9



JavaFX by Sun

Becoming acquainted with Flex 11
Taking advantage of Adobe Flash 11
play together 12 The Flex ecosystem


vii

www.it-ebooks.info



Flex and JavaScript can
12


viii

CONTENTS

1.5

How Flex works

14

The Flex languages
Limitations 17

1.6
1.7

2



Events, events, events

16

What’s new in Flex 4 18
Summary 19

Getting started
2.1

14

21

Flex on the cheap 21
Setting up the compile environment 22 Setting up the editing
environment 24 Next steps (if you’re still interested) 24




2.2

Get serious with Flash Builder 25
Product and pricing matrix

2.3
2.4

26

Getting Flash Builder

26

Exploring Flash Builder 27
Views and perspectives 29
Out-of-the-box perspectives 29
Customizing perspectives 30

2.5





Switching perspectives

Our first project—Hello World!

29

31

Create the project 31 Entering code
run 33 Making it real 33


33



Compile and



2.6
2.7

Using design mode 34
Built-in reference and API documentation

35

Object-oriented languages and their APIs 35 Accessing the API
Reference 36 Perusing the API Reference 37




2.8

MXML and ActionScript in a nutshell 38
The structure of MXML 38 How MXML and ActionScript
relate 39 Events are handled by ActionScript 40




2.9

3

Summary

42

Working with ActionScript
3.1

Comments

45

Inline comments

3.2

Variables

44

45



Block comments

45

45

Variable names 46 Strict data typing 46
dynamic type checking 46 Top-level classes
Special data types 48




www.it-ebooks.info



Static versus
47


ix

CONTENTS

3.3

Loops

48

For (starting value; valid condition; increment) 48 For (property
names in array/object) 49 For each (item in array/object) 50
While (condition) 50 Do while (condition) 50






3.4

Conditional statements (if statements and switches) 51
If..else

3.5

Arrays

51



Switch 53

54

Indexed arrays

3.6

Associative arrays



ActionScript tidbits
Braces

3.7

54

58



58

Logical operators and shortcuts

59

Sneak peek at functions, classes, and packages
Your own functions 62
individual files 65

3.8

56

61

Separating ActionScript to



Simple data binding 66
Life without binding 66 Adding binding 67 The binding
tag 67 Making ActionScript variables bindable 68






3.9

4

Summary

69

Layout and containers
4.1
4.2
4.3

70

Spark versus Halo (MX) 71
Absolute layout 72
Constraint-based layout 74
Basic constraints

4.4

74

Automatic layout



81



Getting spaced out

82

Variable and fixed sizing 83
Variable sizing

4.6

76

80

Using the layout classes

4.5

Enhanced constraints

Containers

83

Fixed sizing



83

84

Application container 84 Canvas container 86
Group-based containers and SkinnableContainer 86
Panel container 88 ApplicationControlBar container 89
DataGroup and SkinnableDataContainer 90 DividedBox,
HDividedBox, and VDividedBox containers 92 Form
container 93 Grid container 94










4.7

Summary

95

www.it-ebooks.info


x

CONTENTS

5

Displaying forms and capturing user input
5.1
5.2

The id attribute 97
Flex’s catalog of controls

96

98

Text controls 98 Date controls 101 Numeric controls
Exploring Flex’s buttons 105 Picklist controls 109




102



5.3

Accessing the control’s value

112

Passing values to a function 112 Passing events to a
function 112 Accessing properties directly 114 Which
approach to use 115




5.4

6

Summary



115

Validating user input
6.1
6.2

117

Overview of validation 118
Built-in validators 118
Validator 119 StringValidator 121
NumberValidator 122 DateValidator 123
EmailValidator 124 CreditCardValidator 125
CurrencyValidator 127 PhoneNumberValidator 128
RegExpValidator 128 SocialSecurityValidator 130
ZipCodeValidator 131










6.3
6.4
6.5
6.6
6.7

Real-time validation 132
Committed value validation 133
Pass-through validation 133
Scripted validation 134
Validation tidbits 135
Does a validator always check all criteria? 135 Validating what
was entered vs. criteria matching 135 Controlling what triggers
validation 136




6.8

7

Summary

Formatting data
7.1

136

138

Built-in formatters

139

Formatter 139 NumberFormatter 140
CurrencyFormatter 142 DateFormatter 143
PhoneFormatter 146 ZipCodeFormatter 147
SwitchSymbolFormatter 149






7.2

Real-time formatting 150

www.it-ebooks.info


xi

CONTENTS

7.3

Scripted formatting 150
Using a function with a formatter component 150
Using a function with a formatter class 151

7.4
7.5

8

Working with formatting errors
Summary 154

MX DataGrids, Lists, and Trees
8.1

MX List genealogy

153

155

156

ListBase and AdvancedListBase’s properties
MX ListBase events 158

8.2

Understanding collections and the dataProvider 158
Feeding the dataProvider 158
Users of collections 159

8.3
8.4

156



Types of collections

159

Initializing collections 160
Populating collections 161
List 161 HorizontalList 163
DataGrid 166 Tree 171




TileList

164



8.5

Interacting with MX List-based components

173

List events 173 Passing the event to a function 173
Passing data to a function 175 Accessing the selected row
directly 176 Binding to a selected row 176






8.6

9

Summary

177

Using the Spark List controls
9.1

Spark List genealogy

178

179

Identifying the proper component using namespaces
Item renderers with Spark List-based controls 179

9.2

Spark List-based controls

179

180

The ButtonBar control 180 The Spark List control
The DropDownList control 183

181



9.3

Interacting with Spark List-based components
Default event dispatching on item selection
The IndexChangedEvent object 185

9.4

184

184

Understanding Flex 4 List-based
component architecture 185
Class hierarchy 185
components 185



New Spark classes for List-based

www.it-ebooks.info


xii

CONTENTS

9.5

Building custom List-based components on Spark
Architecture 186
Understanding the Group and SkinnableContainer classes
Building a custom Spark List component 187

9.6

10

Summary

191

List customization
10.1

187

192

Customizing data display

192

The labelField property 193 Label functions 193 Types of
label functions 195 Using a multicolumn label function 196
Uses for label functions 197 The bigger picture 198








10.2

Item renderers

198

Spark MXML item renderers 198 MXML item renderers in
Spark with MX components 200 Creating an inline item
renderer 203 Using drop-in item renderers 204






10.3

Item editors

206

Enabling item editing 206 Creating an item editor
Item editing events 209 Combining forces:
rendererIsEditor
211


207



10.4

Advanced item renderers

211

The AdvancedDataGridRendererProvider 212 Referencing
the column 213 Spanning columns 214 Spanning an
entire row 214




10.5
10.6



Filter functions 216
Summary 217

PART 2 APPLICATION FLOWAND STRUCTURE . ............... 219

11

Events
11.1

221
The event system 222
Event system—the Hollywood Principle
system 224

11.2

Sending and receiving events

223



Event-delivery

225

Adding event listeners in ActionScript 227 Binding
events 229 Removing event listeners 232




11.3

Custom events 234
Dispatching custom event types 234 Creating custom
events 235 Adding event metadata to custom dispatchers
Stopping event propagation 242




11.4

Summary

243

www.it-ebooks.info

240


xiii

CONTENTS

12

Application navigation
12.1

244

Preparing the menu data

245

Nested arrays 245 Nested array collections 246
Models 247 XML component and class 248 XMLList
component 249 XMLListCollection component and class 250








12.2

Working with menus

252

Creating a menu 252 Positioning the menu 254
Customizing menu items 254 Interacting with menus




12.3

Using a menu bar

256

258

Creating a menu bar 258 Positioning the menu bar 258
Customizing items in the menu bar 259 Handling user
interactions with menu bars 260




12.4

Using view stacks 262
Creating a view stack 262 Adding navigation to the view
stack 264 Handling user interactions with view stacks 267




12.5

TabNavigator 268
Creating a tab navigator
tab navigator 269

12.6

Accordion

268



Handling user interactions with a

270

Creating an accordion 270 Populating an accordion
Handling user interactions with an accordion 272


12.7

13

Summary

272

Introduction to pop-ups
13.1

271

273

Creating your first pop-up 274
First things first: create your title window 274 Using
PopUpManager to open the window 275 Closing the
pop-up 276




13.2

Controlling the window location
Using the centerPopUp() method 277
window placement 278

13.3

Data integration with pop-ups

277


Calculating

280

Getting data out of your pop-up window 283 Sending custom
events with data 283 Getting data out 285 Sending data to
the window 286




13.4

Using alerts

288

Creating a simple alert 289
A more advanced alert 289

13.5

Summary






293

www.it-ebooks.info

Doing more with alerts
Pimp this alert 291

289


xiv

CONTENTS

14

Implementing view states
14.1
14.2

294

Understanding view states
View states in Flex 295

294

Working with properties 297 Working with event
handlers 300 Utilizing state groups 302 Adding and
removing components 305 Reparenting components 309
State events 311








14.3
14.4

15

Bring it together 313
Summary 314

Working with data services
15.1

316

Accessing server-side data

317

Using the HTTPService object 318
the WebService component 319

15.2



Action Message Format in action

Consuming web services with

320

Open-source AMF 321 AMF with PHP 322 AMF and
ColdFusion 322 BlazeDS 322 LiveCycle Data
Services 323 Additional technologies 323










15.3

Building data-centric applications with Flash Builder 323
Setting up the right environment
the server 324

15.4
15.5
15.6

323



Establishing connection to

Data-centric Flex with ColdFusion 332
Data-centric Flex with Java EE and BlazeDS 334
Binding the model to the view 335
Drag-and-drop data binding 335 Generating a Master-Detail
form 337 Flash Builder code review 338




15.7

16

Summary

340

Objects and classes
16.1

341

OO theory in five minutes 342
The relationship between objects and classes 342 Objects have
properties and methods 342 Inheritance 343
Encapsulation and coupling 344




16.2

Playing with objects

346

A closer look at objects 346 Methods of objects 347
parameters 348 Methods return information 348




www.it-ebooks.info



Method


xv

CONTENTS

16.3

Creating a class

349

Creating the class file 349 Specifying a package 350
Class modifiers 350 Superclasses: extending a class 351
Interfaces 351 Looking at your class 351






16.4

Working with properties
Adding properties

16.5
16.6

17



Adding geter/setter methods

Creating methods for your class
Summary 357

Custom components
17.1

353

352

Understanding Flex 4 components
359

359

The many flavors of custom



Creating simple custom components
Build your own simple ComboBox
components 365

17.3

355

358

Spark component architecture
components 360

17.2

353

364

363


Simple Spark

Skinning with the Spark Skin object 366
Using metadata to bind component skins 368
Custom
component view states 368 Defining skin parts 369
Declaring the host 370




17.4

Composite components

370

Halo versus Spark 371 Spark layout classes
MXML composite components 373


17.5

Creating advanced Flex 4 components
Using ActionScript to build the state selector
to override 376

17.6

372



Creating

375
375



Knowing when

Get your components to communicate 381
Use getters and setters as property proxies 381 Binding variables
to component properties 383 Use events to pass data 384




17.7

18

Summary

386

Creating reusable components
18.1

388

Putting reusability into action

389

Reveal component background 389 Theory and concepts in
Spark reusability 389 Creating the Reveal component 391
Skinning the first Reveal 394




www.it-ebooks.info


xvi

CONTENTS

18.2

Reveal gets a new look 396
Implementation of the Reveal controls

18.3

Runtime shared libraries

397

400

Understanding SWC files 400 Types of RSLs
your Flex application use the RSL 402


18.4

19

Summary

Making

405

Flex-driven design patterns

406

The Model-View-Controller pattern
architecture 408

19.2



404

Architectural design patterns
19.1

400

407



Introduction to microarchitectures

Roll your own

413

What is a microarchitecture? 413 Why use a
microarchitecture? 414 First-generation microarchitecture 414
Second-generation microarchitectures 416 Inversion of Control
and dependency injection 417






19.3

Using the Robotlegs framework 418
Injecting dependencies with Robotlegs 419 Configuring
dependency injection with the Robotlegs mapping utilities 420


19.4

Creating an application with Robotlegs MVCS 426
Setting up a Robotlegs project 426 Bootstrapping your
application with the Context class 427 Mediating your
views 429 Taking control with Robotlegs commands 434
Services are the gateway to the world 436 Using the model to
manage data and state 438








19.5

Summary

440

PART 3 THE FINISHING TOUCHES . ............................... 441

20

Customizing the experience
20.1

443

Principles of user experience design
Building around user stories
The VIBE model 448

20.2

444



444

Considering context

445

Visual appeal 448
Using and creating themes
with CSS 451

448

www.it-ebooks.info



Styling Flex 4 applications


xvii

CONTENTS

20.3

Interactive experience

456

Declarative design with FXG and Flash Catalyst CS5
Enhancing the experience with effects 459

20.4

Business optimization

456

461

Using best practices to improve the experience 461 Improve
the experience by unit testing 463 Profiling Flex 4
applications 463




20.5

Extensibility

464

Extensibility’s indirect relationship to user experience 465
The direct relationship between extensibility and user
experience 465 Write clean code for the sake of usability


20.6

21

Summary

468

Working with effects
21.1

469

What’s an effect? 469
Available effects

21.2

466

Using effects

470

Composite effects



471

471

Cause and effect 471 Event-triggered effects 472
Programmatically applying an effect 473 Using state
transitions to trigger effects 477




21.3

Creating composite effects
Sequential effects 478
composites 480

21.4

Exploring effects



478

Parallel effects

479



Composite

482

The Animate effect 482 Animating filters with
AnimateFilter 490 Animating pixel shaders with
AnimateTransitionShader 493 Customizing effect
easing 496 Maintaining fonts while animating 498
Creating sound effects 500








21.5

22

Summary

Drag-and-drop
22.1

501

502

The drag-and-drop process
Drag-and-drop events

22.2

503

504

Implementing drag-and-drop in Flex components

505

Components with native drag-and-drop support 505 Enabling
D&D on Lists 506 Moving versus copying 507 Using
D&D for user-controlled sorting 508 Multi-item drag-anddrop 509 Two-way drag-and-drop 511










www.it-ebooks.info


xviii

CONTENTS

22.3

Enter the DragManager

512

DragManager properties and methods 512 Accepting or denying
a drop 513 Applying your own drop 516




22.4

Adding D&D to non-List components

518

Setting up the example 518 Initiating the drag 519
Using a custom drag proxy 521 Handling the drop 523




22.5

Customizing the drag-and-drop experience

526

Changing the drag proxy icons 526 List component skinning for
drag-and-drop 527 Mixing drag-and-drop between Spark and
Halo 528




22.6

23

Summary

529

Exploring Flex charting
23.1

Introduction to charting
Chart parts

23.2
23.3

530

531

530

Chart types overview



Setting the stage with series and data
Creating charts 533

531

532

Invoking a chart 534 Adding a legend 535
chart types 536 Filtering chart data 538




Changing



23.4
23.5

Stacking charts 539
Exploring chart types

540

Area charts 540 Bar charts and column charts 541 Line
charts 543 Bubble charts 544 Candlestick and HLOC
charts 546 Pie charts 549 Plot charts 551










23.6

Customizing charts
Series strokes

23.7

24



Summary

553



553
Series fills

554

556

Debugging and testing 557
24.1

Debugging

558

Setting up the Flash Debug Player 558 Using the trace()
function 559 Using the Flash Builder debugger 560
Monitoring network activity 565




24.2
24.3

Flex profiler 566
Testing your applications with automation
Unit testing 570

24.4

Summary



Functional testing

578

www.it-ebooks.info

575

570


xix

CONTENTS

25

Wrapping up a project
25.1

Customizing the HTML wrapper
Wrapper files 580
SWFObject 2 582

25.2

579


579

The HTML template

581

Deployment 584
Creating a production build 584 Positioning client-side
files 585 Positioning server-side files 586 Testing your
application 586




25.3

Summary
index

587

589

Bonus Chapter 26 Working with XML
Available online at
www.manning.com/Flex4inAction

www.it-ebooks.info




foreword to the first edition
The ability to create Rich Internet Applications (RIAs) has been around much longer
than the term itself; since version 8, the Flash Platform has been a viable RIA platform.
But it was initially geared toward designers using the environment from a creative perspective, which wasn’t ideal for those coming from a pure development background.
If you were a Flash application developer, major hurdles still remained in your way.
Delivering feature-laden rich applications in a productive and timely manner was difficult because you had to do most of the work yourself.
The challenge became clear and simple: provide a pure development environment
that leveraged the ubiquity and capabilities of Flash yet catered directly to developers
and their systems-development lifecycle. Give developers tools to be productive, and
give them a framework that did most of the hard work for them so that they could
focus their efforts on application logic. The solution to this challenge was Flex.
Flex has been on quite a journey since its release in March 2004 by Macromedia.
That first version was followed by the more widely distributed version 1.5 later that
year. Flex started as a server product and was billed as a way for developers to create
applications on the Flash Platform.
This opened up a whole new world and helped light the fire for RIAs. As Flex-based
RIAs began to gain traction, it proved that a demand existed for RIAs and that the general premise for the technological approach was sound. The next step would be to
bring RIAs to the masses.
Now under the Adobe brand, the product made a huge jump with the release of
Flex 2 in June 2006. Performance was greatly improved as a result of a language overhaul (ActionScript 3) and a major update to the Flash Player (V9).
xx

www.it-ebooks.info


FOREWORD TO THE FIRST EDITION

xxi

The tooling switched to the Eclipse platform, which gave it instant credibility with
programmers. Flex 2 saw the split of basic compilation and server-side data management. We also saw the first release of the free SDK for compiling Flex apps outside of
the IDE. The server-side component evolved into Flex Data Services, now known as
LiveCycle Data Services, which enabled real-time data sharing.
These changes helped legitimize the idea of RIAs by proving a desktop experience
was possible inside of the browser. At this point, what RIAs needed most was community support.
Tariq saw the need for community support and was there from the very start. He
began by creating the first portal and community dedicated to Flex—also known as
Community Flex (CFLEX.Net).
CFLEX.Net aggregated tips, tricks, blog posts, events, and technical articles about
how to get started with this new framework. Tariq was instrumental in contributing
content to the early Flex community, and I owe many of my Flex skills to him.
Early on, Tariq grasped the importance of data services and how real-time data can
help complete a Rich Internet Application. He’s built everything from internal
business-facing Flex applications to great consumer applications. He’s seen and used
everything the platform has to offer, which is one of many reasons he’s an ideal author
for a Flex book. I think it’s long overdue that this recognized expert’s work be bound
and made portable.
The release of Flex 3 brings us to a new and exciting stage in the framework and
the technology. Adobe open-sourced much of the Flex platform in an effort to be as
transparent as possible and to incorporate valuable feedback (not to mention great
code) from the community.
With the release of the Adobe AIR, developers can now use Flex to deploy desktop
applications as well as browser-based applications.
Adobe has long been known for its great design tools. Flex 3 is the first release that
allows designers using those tools to seamlessly collaborate with developers to create
great-looking Flex applications. Numerous productivity enhancements in the framework and Flex Builder also make it easier for new developers to get started and scale
their applications.
Regardless of your development background or experience with Flex, you’ll find
Flex 3 in Action to be an invaluable guide. There is something for everyone in this
book. Tariq and his coauthors Jon and Faisal provide a must-have for any Flex library.
This is to be expected from the star who has provided the Flex community with the
must-have resource we all know and love, CFLEX.Net.
R YAN STEWART
PLATFORM EVANGELIST
ADOBE SYSTEMS, INC

www.it-ebooks.info


preface
For many decades user experience was a generally low priority; up until the mid-2000s
the term barely existed. It wasn’t taught in software engineering university programs,
and businesses weren’t cognizant of user experience and design (also known as UXD).
Over the years, however, UXD has become a first-class citizen and a top priority, particularly for public-facing web applications. Supporting that are some awesome webbased technologies that allow developers to create these rich internet applications.
But it wasn’t always so awesome. Back in the day (early 2000s) I’d been searching
for a way to provide users with a better online experience. It took time before Google
wowed everyone with the innovative Google Maps site, so for a long time users didn’t
know how much better things could be.
Through the years of using the web for document distribution, users’ expectations
devolved from the power of native desktop applications to the anemic ability of HTML
applications. That’s not a knock against HTML and the web; the web is perfect for
what it does, which is deliver platform-neutral documents. Developers and companies
focused on the web’s ability to give them time-to-market rapid application development, and users accepted whatever was in front of them because, hey, that’s how web
applications are, right?
It bothered me that with every click, a backend system executed a lot of code to
result in minimal UI changes. Even worse was the constant bombardment of database servers. For a technologist, the quick remedy to this is simple: Slap in more
memory, load up on virtual machines, scale out horizontally with low-cost commodity servers, and call it a day. But I’m talking about the cost to the users. On their end,
they were experiencing that annoying click-and-wait feeling that was common for

xxii

www.it-ebooks.info


PREFACE

xxiii

web applications. In addition, UIs were limited. Sure, you could use JavaScript, but
you could only go so far before you needed advanced skills. From an ROI perspective, it generally wasn’t worth it.
At the time, Java applets and Flash were available, and they seemed to offer the
potential to achieve what I was looking for. But applets failed as a solution; they were
bloated, slow, and inconsistent across platforms. Flash was promising, but trying to
produce enterprise business applications in a designer’s environment proved to be
more challenging than it was worth.
During my time in the Knowledge Management department at eBay, this challenge
came up again. I needed a way to abstract the complexity of the data and make it simple for users to work in a visual environment.
Along came Flex in 2004 (V1 initially and V1.5 shortly after that). I was able to
make a business case for using it, and our team delivered experiences at an entirely
new level. At this point, I knew Flex would be big. It delivered the desktop power users
needed while maintaining the development velocity that software teams required to
survive.
As a believer in Flex, I made it a personal mission to help grow the Flex community. I created CFLEX.Net (www.cflex.net), believing that the bigger the community,
the more it will reinvest in itself through knowledge and code sharing and in this way
continue to boost the technology’s adoption rate. If there’s a strong support network,
you take less of a risk in bringing a new technology into your organization.
For the early adopters of Flex, the learning curve was rough because only a limited
number of books and other reading material were available. That changed with the
release of Flex 2, when the number of resources dramatically increased.
I left eBay in late 2005 to join Amcom Technology and build and manage a team
of developers. As with any new technology, experts in the field are hard to come by, so
your best bet is to grow the skill. While training developers on Flex, I found that the
current set of books didn’t map to how they think and that obvious challenges were
never addressed.
In continuing my mission of growing the community, I set out to write Flex 3 in
Action, hoping it would help solve the learning challenges that everyday developers
face. Instead of grouping topics based on feature categories, the book is structured
according to the natural progression of creating an application. I focused on maximum simplicity by not introducing anything you don’t need to know until it was
needed and by using small code examples that are easy to absorb. I also found that
people learn best when they’re able to relate new things to things they already know,
so whenever possible, I use analogies to how you’d do things in another technology.
With this Flex 4 version of the book, I brought on some industry heavy hitters
(Dan Orlando, John C. Bland II, and Joel Hooks) to help take it to a higher level in
order to provide you with a solid foundation of understanding. My hope is that by
teaching you the keys to success, the Flex community will expand as a result, because
you too will be able to share your knowledge and experience with those around you.

www.it-ebooks.info


xxiv

PREFACE

Now is the time to get into Flex. The community continues to grow, more and
more third-party vendors are coming out with Flex-related technologies, and Flex user
groups are popping up all over the place.
The RIA space is red hot with technologies and competition, but Adobe continues
to prove it’s a few steps ahead. We’re in for some exciting times! HTML web applications will always have a place, but it’s time to take your skills to another level, because
the industry is moving forward with or without you.
Sit down, buckle up, and strap in for the ride!
TARIQ AHMED

www.it-ebooks.info


Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Tải bản đầy đủ ngay

×