1. Trang chủ
  2. » Công Nghệ Thông Tin

Adobe press adobe flex 2 training from the source oct 2006 ISBN 032142316x

1K 102 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 1.026
Dung lượng 9,62 MB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

This title covers the new development framework for Rich Internet Applications, Adobe Flex 2.. In the course of the book, the reader will build several Web applications using Flex Builde

Trang 1

By Jeff Tapper, James Talbot, Matt Boles, Ben Elmore,Mike Labriola

Publisher: Adobe Press Pub Date: October 20, 2006 Print ISBN-10: 0-321-42316-X Print ISBN-13: 978-0-321-42316-0 Pages: 624

Table of Contents | Index

Part of the Adobe Training from the Source series, the official curriculum from Adobe, developed by experienced trainers Using project-based tutorials, this book/CD volume is designed to teach the techniques needed to create sophisticated, professional-level projects Each book includes a CD that contains all the files used in the lessons, plus completed projects for comparison This title covers the new development framework for Rich Internet Applications, Adobe Flex 2 In the course of the book, the reader will build several Web applications using Flex Builder and incorporating MXML and ActionScript 3.0.

Trang 2

By Jeff Tapper, James Talbot, Matt Boles, Ben Elmore,Mike Labriola

Publisher: Adobe Press Pub Date: October 20, 2006 Print ISBN-10: 0-321-42316-X Print ISBN-13: 978-0-321-42316-0 Pages: 624

Trang 9

Notice of Rights

All rights reserved No part of this book may be reproduced ortransmitted in any form by any means, electronic, mechanical,photocopying, recording, or otherwise, without the prior writtenpermission of the publisher For information on getting

Throughout this book, trademarked names are used Ratherthan put a trademark symbol in every occurrence of a

trademarked name, we state that we are using the names in aneditorial fashion only and to the benefit of the trademark ownerwith no intention of infringement of the trademark

Notice of Liability

The information in this book is distributed on an "As Is" basis,without warranty While every precaution has been taken in thepreparation of the book, neither the author, Adobe Systems,Inc nor the publisher, shall have any liability to any person orentity with respect to any loss or damage caused or alleged to

be caused directly or indirectly by the instructions contained inthis book or by the computer software and hardware productsdescribed in it

Printed and bound in the United States of America

Trang 10

Dedication

My efforts on this book are dedicated to my wife Lisa and daughter Kaliope Everything I do, I do for you two.

Jeff Tapper

My efforts are dedicated to my family and friends as well

as the Adobe Training and Consulting teams for giving me the incredible opportunities that have allowed this book to come to be.

James Talbot

To friends.

To Sandra, my best friend and wife, who has helped and supported me in so many ways over the years Thanks for supporting me even when I chose to do crazy things,

including writing this book.

To my siblings, Melissa, Todd, Jody, and Kent (and their wonderful families) who continue to be better and better friends with each passing year.

To Bryan and Colleen, who prove that once built, a solid friendship can't be diminished with time or distance.

To Bob and Connie, who were willing to be friends when I needed it most, even at the expense of their time.

To Sue, Robert, James, Deborah, Tina, Cathrine, Leo, Jon, and Jim, who are not only my colleagues in Adobe

Customer Training, but who have also become great

friends.

Trang 11

This book is dedicated to my kids Olivia, Haydn, Sydney, Carrington, and Griffen It is always hard to take time away from you for such a task as writing.

Benjamin Elmore

To my wife Laura; you always make me smile.

Michael Labriola

Trang 12

Jeff Tapper is the Chief Technologist and CEO for Tapper,

based applications since 1995 for a myriad of clients includingMorgan Stanley, Doctations, Toys R Us, IBM, Dow Jones,

Nimer and Associates, Inc He has been developing Internet-American Express, M&T Bank, Verizon, and many others Hehas been developing Flex applications since the earliest days ofFlex 1 As an Instructor, Jeff is certified to teach all of Adobe'scourses on Flex, ColdFusion, and Flash development He is also

a frequent speaker at Adobe Development Conferences and

user groups Jeff Tapper and Mike Nimer formed Tapper, Nimerand Associates provide expert guidance to rich Internet

application development and empower clients through

mentoring

James Talbot has been with Adobe (formerly Macromedia) for

more than six years, on both the sales engineering and trainingteams, and has most recently been working with Flex and FlashLite He has traveled extensively throughout the world

promoting Adobe products and certifying Adobe instructors aswell as speaking at conferences James has been an integralteam member on high profile rich Internet application

consulting assignments for companies such as AOL/Time

Warner, JP Morgan, Fidelity, and TV Guide

James is actively involved in the Adobe worldwide instructor anddeveloper community, and contributes to developer certificationexams as well as organizing and speaking at user groups

James is passionate about Flash on devices as well as rich

Internet applications and he believes that both technologies willchange the world for the better

Matthew Boles is the Technical Lead for the Adobe Customer

Training group and has been developing and teaching courses

on Flex since the 1.0 release Matthew has a diverse

Trang 13

of technologies Ben founded Twin Technologies with a core

principle of embracing a shared knowledge base within the

development community When leading Twin Technologies, Bentravels to Africa and Turkey to speak on leadership on behalf ofthe EQUIP organization (www.iequip.org), whose goal is to raise

developers to work with Flex; his afternoons creating rich

Internet applications that generate significant ROI for clients;and his nights dreaming up ways to use Flex that its designersnever intended

Trang 14

I would like to thank Matt, James, Ben, and Mike for alltheir hard work, which has helped shape this book

Special thanks go to the team at Adobe/Macromedia,

which has made this all possible, especially the efforts ofDavid Mendels, Phil Costa, and Mike Nimerall of whomhave offered invaluable advice during this process Thanks

to Tad Staley of Adobe consulting, who has given me moreopportunities than anyone else to work on Flex projects Iwould also like to acknowledge Doctations and the IT

Reference Data department at Morgan Stanley, clients

whose Flex 2 projects coincided with the writing of thisbook This book couldn't possibly have been written

without the lessons I learned on their projects, nor couldtheir projects have been successfully completed without

my work on this book Thanks to the editorial staff at

Adobe Press, who was faced with the Herculean task ofmaking our writings intelligible Finally, thanks to the 2004World Series Champion Boston Red Sox

Jeff Tapper

This book has consumed many, many hours and sleeplessnights, but it is all due to the incredible efforts of Jeff,

Matt, Ben, and Michael I would like to thank each one ofthem and offer a special thanks to Michael and Robyn.This book could not have been a success without the

incredible steadfastness of both Michael and Robyn, whodemonstrated incredible eagle eyes and never wavered intheir resolve to publish the very best Thanks to everyone

at Adobe, including David Mendels, Sho Kuwamoto, EricAnderson, Phil Costa, and everyone else on the Flex andFlex Builder teams I'd like to offer a special thanks to

Robert, Sue, Leo, Cathrine, and Jazmine on the Adobe

Trang 15

James Talbot

Getting this book finished has been a long and arduousroad, and I could not have completed the journey withoutJeff, James, Mike, Ben, and Robyn I hope Mike can

forgive me for getting him involved in a project that hastaken much more time than either of us could have everimagined I also hope Robyn can forgive all of the authorsfor making this such a long project Josh and the rest ofthe gang at Digital Primates deserve kudos for the workthey have done in testing this book Thanks also to DaveMendels, Phil Costa, Sho Kuwamoto, Heidi Williams, andthe rest of the Flex and Flex Builder teams for buildinggreat products and helping me understand them Alsothanks to Bob Tierney and Kevin Hoyt for giving doses ofreality Flex when needed

Matthew Boles

I heard someone once say that the best part of writing iswhen it is over and you get to see the benefit of your

labor My part in this book was a simple one and I wouldlike to acknowledge the great work done by my co-

authors who shouldered the largest share Thank you forthe opportunity to assist with the book; it was a pleasure

At a recent technology get-together I ran into my firstmentor, Greg Fisher My experience in life has shown methat you can either hoard or share your knowledge withthose around you I am grateful for your willingness somany years ago to choose to invest and share with me.Finally I would like to acknowledge the sacrifice and

support of my wife Mary, the object of my eternal

Trang 16

Benjamin Elmore

I would like to thank Matt, Jeff, James, and Ben for theirwork and dedication to bringing this project together

Thanks to Robyn for her diligence, understanding and

patience during the process Thanks to Josh, Jim, andPeter of the Digital Primates' team for hours of reading,running code, supporting my half-thought-out ideas, andgenerally being great friends and colleagues Thanks toShirl for her candor and counsel, and specifically for

pushing me in this direction Thanks to Matt for inviting

me to join this project and team Thanks to my family forthe encouragement they always provide Finally, thanks to

my wife Laura, who supports my craziest ideas with a

smile and a lot of understanding

Michael Labriola

Trang 17

It's just a few short years since Macromedia coined the term

rich Internet application Back then, the idea felt somewhat

futuristic, but all that has changed rich Internet applications (orRIAs, as we affectionately refer to them) are reality and theyare here right now

Macromedia released Flex a couple of years ago, making it

possible for developers to write applications that take

advantage of the incredibly prevalent Flash platform These

applications don't just look great; they also are truly portable,can be fully accessible, and (most importantly) dramatically

change the end user experience replacing the page request

model of the web to something far more elegant and usable.Something richer

Numerous organizations have discovered the benefits of Flexand have successfully built and deployed applications that run

on top of the Flash platform The highest profile of these is

Yahoo!, which created the next generation of Yahoo! Maps inFlex But despite the early Flex successes, Flex 1 was most

definitely not a mass market product Pricing, tooling,

deployment options, and more meant that Flex 1 was targetedspecifically for larger and more-complex applications, as well asfor more-sophisticated developers and development But thishas now changed

Now part of the Adobe family, Flex 2 was released mid 2006abrand new Flex with a new integrated development

environment (IDE), new pricing, new deployment options, anew scripting language, and a brand new Flash Player too Flex

2 is most definitely a mass market product, designed to bringthe values and benefits of RIAs to all developers

Getting started with Flex is pretty easy MXML tags are easy to

Trang 18

you) ActionScript has a steeper learning curve, but developerswith prior programming and scripting experience will pick it upeasily But there is more to Flex development than MXML andActionScript

There are many things that need to be understood to be a

successful Flex developer, including the following:

How Flex applications should be built (and how they shouldnot)

Relationships between MXML and ActionScript, and when touse each

Various ways to interact with back-end data, and the

differences between each

How to use the Flex components, and know how to writetheir own

Performance implications of the code they write and how it

is written

Best practices to write code that is scalable and manageableand reusable (there is definitely more to Flex than MXMLand ActionScript)

And this is where this book comes in Matthew Boles, JamesTalbot, and Jeff Tapper (ably assisted by Benjamin Elmore andMichael Labriola) have distilled their hard-earned Flex expertiseinto a series of lessons that will jump-start your own Flex

development Starting with the basics and then incrementallyintroducing additional functionality and know-how, the authorteam will guide your journey into the exciting world of RIAs,

Trang 19

Flex 2 is powerful, highly capable, fun, and incredibly addictive,

too And Adobe Flex 2: Training from the Source is the ideal

tour guide on your journey to the next generation of applicationdevelopment

of the World Wide Web, the better off you'll be This book iswritten assuming that you are comfortable working with

programming languages and are probably working with a

server-side language such as Java, Net, PHP, ColdFusion, or asimilar technology Although knowledge of server-side

technologies is not required to succeed with this book, there aremany comparisons and analogies made to server-side web

programming This book is not intended as an introduction toprogramming or as an introduction to object-oriented

programming (OOP) Experience with OOP is not required,

although if you have no programming experience at all, youmight find the materials too advanced

Outline

As you'll soon discover, this book mirrors real-world practices asmuch as possible Where certain sections of the book departfrom what would be considered a real-world practice, every

Trang 20

designed to get you using the tools and the interface quickly sothat you can begin to work on projects of your own with as

Trang 21

www.flexgrocer.com Of course, you must have an Internet

connection to access this site In lieu of this, you can start theColdFusion server instance, as detailed in the appendix, "SetupInstructions," and change the URL from

Trang 22

function as void" or "Data type the function as String." This isjust to make the instructions simpler; the authors realize thefunction itself is not data typedwhat is really being data typed isthe value the function returns

Who Is this Book For?

Macintosh and Windows users of Flex Builder 2 can complete allthe exercises in Lessons 1-16 Lessons 17-25, however, coverFlex Data Services, which only runs under Windows Macintoshusers can continue with those Chapters if they have access to aFlex Data server running on a separate machine Setting upthat server and connecting to it is, alas, beyond the scope ofthis book

The Project Application

Adobe Flex 2: Training from the Source includes many

comprehensive tutorials designed to show you how to create acomplete application using Flex 2 This application is an "onlinegrocery store" that displays data and images and then submitscompleted orders to the server It includes an executive

Dashboard to enable store managers to view real-time graphsshowing sales details, as well as a data-entry application foradding or editing the products sold by the grocery

By the end of 25 hands-on lessons, you will have built an entireweb site using Flex You will begin by learning the fundamentals

of Flex and understanding how Flex Builder can be used to aid

in developing applications In the early lessons, you will makeuse of Design mode to begin laying out the application, but asyou progress through the book and become more comfortablewith the languages used by Flex, you will spend more and moretime working in Source mode, which gives you the full freedomand flexibility of coding By the end of the book, you should be

Trang 23

probably work even without Flex Builder by using the freelyavailable Flex 2 SDK and command-line compiler

Standard Elements in the Book

Each lesson in this book begins by outlining the major focus ofthe lesson at hand and introducing new features Learning

objectives and the approximate time needed to complete all theexercises are also listed at the beginning of each lesson Theprojects are divided into exercises that explain the importance

of each skill you learn Every lesson will build on the conceptsand techniques used in the previous lessons

Tips ( ): Alternative ways to perform tasks and suggestions

to consider when applying the skills you are learning

Notes ( ): Additional background information to expand your

knowledge and advanced techniques you can explore to furtherdevelop your skills

<mx:HorizontalList dataProvider="{dp}"

labelFunction="multiDisplay"

columnWidth="130"

width="850"/>

Trang 24

Code in text: Code or keywords appear slightly different from the

Trang 25

an intermediate directory, which contains files in various stages

of development in the lesson Any time you want to referenceone of the files being built in a lesson to verify that you arecorrectly executing the steps in the exercises, you will find thefiles organized on the CD-ROM under the corresponding lesson.For example, the files for Lesson 4 are located on the CD-ROM

in the Lesson 4 folder

The directory structure of the lessons you will be working with

is as follows:

[View full size image]

Trang 26

lessons, completed projects for comparison, and more

Adobe Authorized Training and Certification

This book is geared to enable you to study at your own pacewith content from the source Other training options exist

Trang 27

You will develop the skills you need to create and maintain yourown Flex applications as you work through these lessons

By the end of the course, you will be able to:

Use Flex Builder to build Flex applications

Understand MXML, ActionScript 3.0, and the interactions ofthe two

Trang 28

700MB of available hard-disk space

Java Virtual Machine: Sun JRE 1.4.2, Sun JRE 1.5, IBM JRE1.4.2

Macintosh

Flex Builder for Macintosh is not available at the time thisbook went to the printers, but is expected shortly

The Flex line of products is extremely exciting, and we're

waiting to be amazed by what you will do with it With a strongfoundation in Flex, you can grow and expand your skillset

quickly Flex is really not too difficult to use for anyone withprogramming experience With a little bit of initiative and effort,you can fly through the following lessons and be building your

Trang 29

own custom applications and sites in no time.

Trang 30

Lesson 1 Understanding Rich Internet Applications

Trang 31

Computers have been playing a role in the business

environment for more than four decades Throughout that time,the roles of the client and server have been constantly evolving

As businesses and their employees have become more

comfortable delegating responsibilities to computers, the look,feel, and architecture of computerized business applicationshave changed to meet the new demands This evolving processcontinues today, as businesses are demanding faster, lighter,and richer Internet applications In this lesson, you will learnabout this evolving nature and understand the business

requirements that push us to build rich Internet applications(RIAs)

You will use Flex to build the FlexGrocer application seen here.

[View full size image]

Trang 32

Applications

In the earliest days of computerized business applications, allprocessing took place on mainframes, with the client having norole other than to display information from the server and

accept user input This was largely dictated by the high cost ofprocessing power It simply was not affordable to spread

powerful clients throughout the enterprise, so all processingwas consolidated, and "dumb terminals" provided the user

everything, adding many challenges for centralizing businessrules and synchronizing data across the enterprise

To help resolve this issue, several vendors released platformsthat sought to combine the strengths of the microcomputer withthose of the mainframe, which led to the birth of client/serversystems These platforms afforded end users the power andease of microcomputers while allowing for business logic anddata to be stored and accessed from a centralized locationwhichsolved the problems of the day The new challenge introducedwith the client/server systems was distribution Any time

changes needed to be made to client applications, IT

departments had to manually reinstall or upgrade the software

on every single desktop computer Many companies found theyneeded a full-time staff whose primary responsibility was

Trang 33

With the explosive growth of the Internet in the 1990s, a newmodel for business applications became available This modelworked by having a web browser act as a thin client, whose

primary job was to render HTML and send requests back to anapplication server that dynamically composed and delivered

pages to the client This is often referred to as a "page-based

architecture." This model successfully solved the distributionproblem of the client/server days; the application was

downloaded from the server each time an end user needed it,

so updates could be made in a single centralized place and

automatically distributed to the entire user base This modelwas and continues to be successful for many applications;

however, it also creates significant drawbacks and limitations Inreality, Internet applications bore a great resemblance to

mainframe applications, in that all the processing was

centralized at the server, and the client only rendered data andcaptured user feedback The biggest problems with this

surrounded the user interface (UI) Many of the conveniencesthat end users grew to accept over the previous decade werelost, and the UI was limited by the capabilities of HTML

For example, desktop software as well as client/server

applications frequently use the drag-and-drop feature However,HTML (Hypertext Markup Language) applications almost neveruse the feature, due to the complexities and lack of cross-

browser support for the DHTML (Dynamic HTML), which it

requires to implement in a pure HTML/DHTML solution

In most cases the overall sophistication of the solutions thatcould be built and delivered was greatly reduced Although theweb has offered great improvements in the ease and speed ofdeploying applications, the capabilities of web-based businessapplications took a big step backward because browser-basedapplications had to adapt to the limitations of the web

architecture: HTML and Hypertext Transport Protocol (HTTP)

Trang 34

from their investments in Internet technology The capability todeliver true value to users is forcing many companies to looktoward richer models for Internet applications; models that

combine the media-rich power of the traditional desktop withthe deployment and content-rich nature of web applications

As Internet applications begin to be used for core business

functionality, the maintainability of those applications becomesmore crucial The maintainability of an application is directlyrelated to the application's architecture Sadly, many web

applications were built with little thought about the principles ofapplication architecture, and therefore they are difficult to

maintain and extend Today, it is easier to build a solid

architecture for an application by providing a clean separationbetween the business, data access and presentation areas, with

the introduction of elements such as Web Services, service-

oriented architecture (SOA) became more feasible for web-based applications

To meet the demands of businesses, RIAs should be able to dothe following:

Provide an efficient, high-performance run time for

executing code, content, and communications In the nextsection of this lesson, you will explore the limitations of thestandard HTML-based applications, and learn that the

traditional page-based architectures have a number of

performance-related challenges

Provide powerful and extensible object models to facilitateinteractivity Web browsers have progressed in recent years

in their capability to support interactivity through the

Document Object Model (DOM) via JavaScript and DHTML,but they still lack standardized cross-platform and cross-

Trang 35

involves building multiple versions of the same application

Enable using server-side objects through using Web

Services or other similar technologies The promise of RIAsincludes the capability to cleanly separate presentation logicand user interfaces from the application logic housed on theserver

Enable use of the applications when "offline." As laptopsand other portable devices continue to grow in popularity,one of the serious limitations of Internet applications is therequirement that the machine running the application beconnected to the Internet Although users can be online thevast majority of the time, business travelers know there aretimes when an Internet connection is not currently possible

A successful RIA should enable users to be productive with

or without an active connection

Trang 36

be sent to the browser and rendered This is one of the

inefficiencies of traditional web applications: each user

interaction requires a new page loading in the browser One ofthe key goals of RIAs is to reduce the amount of extra data

transmitted with each request Rather than download an entirepage, why not download only the data that changed and update

Trang 37

or client/server applications work

Although this goal seems simple and is readily accepted by

developers taking their first plunge into RIA development, oftenweb developers bring a page-based mindset to RIA applicationsand struggle to understand how to face the challenges from thepage-based world, such as, how to "maintain state." For

example, after users log in, how do we know who they are andwhat they are allowed to do as they navigate around the

application?

Maintaining state was a challenge introduced by web-based

applications HTTP was designed as a stateless protocol, in

which each request to the server was an atomic unit that knewnothing about previous requests This stateless nature of theweb allowed for greater efficiency and redundancy because aconnection did not need to be held open between the browserand server Each new page request lasted only as long as theserver spent retrieving and sending the page, allowing a singleserver to handle far more simultaneous requests

The stateless nature of the web added challenges for applicationdevelopers Usually, applications need to remember informationabout the user: login permissions, items added to a shoppingcart, and so on Without the capability to remember this datafrom one request to the next, true application development

would not be possible To help solve this problem, a series ofsolutions was implemented; revolving around a unique tokenbeing sent back to the server with each request (often as

cookies, which are small text files containing application specific

identifiers for an individual user) and having the server storethe user's information

Unlike traditional web applications, RIAs can bypass many ofthese problems Because the application remains in client RAMthe entire time it's being used (instead of being loaded and

unloaded like a page-based model), variables can be set once

Trang 38

A different approach to handling state is just one of many

places in which building applications requires a slightly differentmindset than web application development In reality, web-based RIAs bear more resemblance to client/server applicationsthan they do to web applications

Trang 39

Business Managers

By making it easier for users to work with software, the number

of successful transactions is increasing This increase occursacross many industries and can be quantified by businesses

with metrics, such as increased productivity using intranet

applications or increased percentage of online shoppers whocomplete a purchase More productive employees can drasticallyreduce labor costs while growing online sales increase revenueand decrease opportunities lost to competitors

IT Organizations

Breaking away from page-based architectures reduces the load

on web servers and reduces the overall network traffic Ratherthan transmitting entire pages over and over again, the entireapplication is downloaded once, and then the only

communication back and forth with the server is the data to bepresented on the page By reducing server load and networktraffic, infrastructure costs can be noticeably lower RIAs

developed using sound architectural principles and best

practices can also greatly increase the maintainability of an

Trang 40

End Users

End users experience the greatest benefits of RIAs A well-designed RIA greatly reduces users' frustration levels becausethey no longer need to navigate several pages to find what theyneed nor have to wait for a new page to load before continuing

to be productive Additionally, the time users spend learninghow to use the application can be greatly reduced, further

empowering them Today, there are a number of excellent

applications, which would not be possible without the concepts

of an RIA, such as the Harley Davidson Motorcycle Configuratorand the Kodak EasyShare Gallery applications These easy touse applications give an excellent example of the ease of use anRIA can offer an end user

Ngày đăng: 26/03/2019, 16:10

🧩 Sản phẩm bạn có thể quan tâm